How do I change a player sprite and behavior

Get help using Construct 2

Post » Sun Mar 16, 2014 4:27 pm

Hi there,

So I have a sprite for the main player, i'll just describe it as a vehicle. I would like to be able to press a button and leave the vehicle behind and continue on foot, then go back to it later.

What's the best way to achieve this?
B
4
Posts: 20
Reputation: 242

Post » Sun Mar 16, 2014 5:25 pm

I've managed to get something working but have one flaw with it. When I switch to the player outside of the vehicle and enable "scroll to" for it, it scrolls to it but not completely, it follows it a bit bit the character can run off screen.
B
4
Posts: 20
Reputation: 242

Post » Sun Mar 16, 2014 5:30 pm

okay I worked around it by removing the scroll to behaviours and calling scroll to object when they move instead.
B
4
Posts: 20
Reputation: 242

Post » Sun Mar 16, 2014 5:55 pm

Sorry for the late post took a moment to type everything up ::

What you can do is have two objects PlayerCar and Player. For the PlayerCar object you can have a variable boolean instance called 'isDriving' if you player starts out outside of the car then you can set that to 'FALSE' by default. Then if you are using the 8 Direction for control give the car that behavior but again if the Player starts outside of the car set it to 'DISABLED'. Now on you player object create the 8 direction and Pin behavior.

Now in the event sheet you can have when the player is overlapping the PlayerCar and hit whatever key it is to enter the car set the action to 1) Hide the player 2) Pin player to the car 3) set its 8 direction behavior to 'DISABLED' 4)set the car isDriving to 'True' 5)enable 8 Direction. So now where ever the car move to the Player object would follow invisibly.

When they exit the car 1)set car to isDriving 'False' 2)Disable PlayerCar 8 Direction 3) set Player Visible 4)Unpin Player from PlayerCar 5)Set Player 8Direction to 'ENABLED'.

Is another way of doing it. The isDriving boolean can be used in case certain keys match when the player is on foot. So the key would know which to do depending on if isDriving is set to true.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Mar 16, 2014 6:42 pm

Try this work very good =D, just one thing for exit the vehicle i have add a new Event, when PlayerCar isDriven and on down key ... Then action as you say,
Only one problem i can't use the same key with this method someone have an idea for use the same key ?

If not thanks PhoenixNightly ;)
B
17
S
6
G
1
Posts: 63
Reputation: 1,306

Post » Sun Mar 16, 2014 6:44 pm

What you do first is check if the carPlayer isDriven is set to true of false. Then execute the keys function you need.

So
carPlayer isDriving=True then key do this
else key do that.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Mar 16, 2014 7:10 pm

I don't find the method for check if the boolean variable was true or false =s ...
B
17
S
6
G
1
Posts: 63
Reputation: 1,306

Post » Sun Mar 16, 2014 7:19 pm

Make an event for object playercar and it will say is 'boolean instance set' this will return true or false so create an else for this event in case its not set
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Tue Mar 18, 2014 7:07 am

That's brilliant thanks, I done something very similar, it's surprising how easy it is to pick up construct2. I'm hoping to actually finish a game rather than losing interest half way through. It's going well at the moment!
B
4
Posts: 20
Reputation: 242


Return to How do I....?

Who is online

Users browsing this forum: ismailsawan, ketramtu18, mekonbekon and 10 guests