Move Player Up a Few Pixels On Button Press

Get help using Construct 2

Post » Wed Oct 24, 2012 2:00 am

Right now I have my game set up to use the platform behavior until the F key is pressed and it toggles to 8-way movement. Its suppossed to give the effect of going from running to flying.

My problem is that sometimes when I switch to the "flying/8-way mode" the player will slide a bit to the left or right like they are snapping to a grid before moving normally. I figure I could live with making the player slide upward a few pixels to give it the look of pushing up a little bit when switching to flying.

I imagine I would need to find the current location of the player when the F key is pressed and then tell it to move upwards a few pixels. I'm not sure how to do that or if it is the best solution.

I'm kind of a noob so any help is appreciated.

You can go here to see the sliding that its doing: Superhero Test
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Wed Oct 24, 2012 1:06 pm

Care to post your capx file?
B
18
S
9
G
5
Posts: 77
Reputation: 4,946

Post » Wed Oct 24, 2012 1:24 pm

Sure, but I'll have to do it when I get home from work. Thanks.
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Wed Oct 24, 2012 4:29 pm

On F key pressed -> set Player.Y to Player.Y-3

Player.Y being whatever the players sprite is called.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Wed Oct 24, 2012 10:42 pm

I believe when you disable the behavior it remembers the speed so when you enable it again it will carry on moving in the direction it was going when you disabled it. Try setting the platform vector x and y to 0 when you disable the platform behavior and use the 8-direction stop action when you disable 8-direction.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Thu Oct 25, 2012 11:31 am

@ramones, that actually sounds like what the problem might be. He tends to slide based on the direction I was holding when I last hit the button. I will try and implement it this weekend.

Here is the Capx in case anyone wanted to see its current state.

Superhero Test

Thanks
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Fri Oct 26, 2012 10:32 am

[QUOTE=EncryptedCow] On F key pressed -> set Player.Y to Player.Y-3

Player.Y being whatever the players sprite is called. [/QUOTE]

@EncryptedCow, That works great, but I just need it to move him up for half a second and then stop subtracting from Y. I tried setting up a "Wait" event within the same toggle, but Construct wouldn't let me add an event after it. Sorry if this is a noob problem.

@ramones, that seems to be exactly what was happening. Thanks!
B
40
S
11
G
6
Posts: 228
Reputation: 6,951


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, SpartCrafter, Yahoo [Bot] and 25 guests