"Knockback" on player hit

Get help using Construct 2

Post » Sat Feb 09, 2013 9:25 pm

Hey there guys! I'm currently working on a pretty simple side scrolling fighting game (think Streets of Rage, Golden Axe, Castle Crashers etc) and i've hit a bit of a problem. The main character has three hit points, and each time you take damage i've managed to make the character fade out for a half second, but one thing I really wanted to do was to make it so once you took a hit, you jumped backwards a bit.

I did have something working with a weird bit of Player.X(-40) coding or something similar (I don't know the first thing about coding, haha) but it didn't work. I feel like i'm missing something simple, but any help would really be appreciated!

http://www.5ifty2wo.co.uk/Ghostwiz2/index.html

This is the current very barebones testing version that I threw together just to show a friend, but i'll put it here just in case it helps at all.

(arrow keys move, A is attack, all you can do at the moment is run, jump, kill, and die)

Thank you for any help you can give me!
B
3
Posts: 9
Reputation: 468

Post » Sat Feb 09, 2013 9:48 pm

should be quite straight forward....


player on collision with enemy
enemy.x > player.x


-->

player.x = player.x - 10
player.y = player.y - 10


EDIT:
quick example: https://dl.dropbox.com/u/45711709/knockback.capxIze2013-02-09 21:56:16
B
33
S
6
G
7
Posts: 338
Reputation: 7,424

Post » Sat Feb 09, 2013 10:48 pm

I couldn't use your example file (says I need construct 1.8 and I only have 1.4) but I managed to get it working thanks to what you posted, so thank you!

Would you happen to know a way to make the player fly backwards, rather than just jumping instantly? I can use this just fine, but it would be useful to know for future reference :)
B
3
Posts: 9
Reputation: 468

Post » Sat Feb 09, 2013 11:27 pm

Well, upgrade to 1.8 then :D

http://www.scirra.com/construct2/releases/r118

Install it to a seperate folder if you don't like beta's

and ofcourse i can make him fly backwards instead:

https://dl.dropbox.com/u/45711709/knockback2.capx
B
33
S
6
G
7
Posts: 338
Reputation: 7,424

Post » Sat Feb 09, 2013 11:45 pm

Use time delta to maintain mobile performance

player.x = player.x - 100 * dt
player.y = player.y - 100 * dtJoannesalfa2013-02-09 23:45:45
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Feb 09, 2013 11:52 pm

[QUOTE=Ize] Well, upgrade to 1.8 then :D

http://www.scirra.com/construct2/releases/r118

Install it to a seperate folder if you don't like beta's

and ofcourse i can make him fly backwards instead:

https://dl.dropbox.com/u/45711709/knockback2.capx[/QUOTE]

Ah this is perfect! Thank you so much! :D

Exactly what i've been looking for. At the moment it was so easy to get chain hit to death, but with this hopefully it'll make it easier on the player. I'm a complete newbie to this all so i've just been trying random stuff that I feel should work but didn't, haha. Thanks again!

B
3
Posts: 9
Reputation: 468

Post » Sun Feb 10, 2013 12:16 am

I tend to use player vector instead of directly setting player.X Also, you can use the flash behavior which may look a bit better than a fade...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests