How do I add a varscore when jump over the enemy?

Get help using Construct 2

Post » Sat Mar 01, 2014 4:53 am

Hi,
I've been looking through a lot of tutorial and couldn't found the situation I'm looking for.
I want a score to count when Player jump over (not kill) the enemy.
The reason is if Player touch Enemy, Player will die.
So to make a score count, Player have to jump over with out touching any part of the enemy.
I found a mario type tutorial and I did try some other way but it didn't work.
Seem like you have to collision with Enemy to make it count. I try to find a way to compare Y with Enemy but still not working.
Anyone know what should I do?
Thanks,
B
4
S
1
G
1
Posts: 6
Reputation: 842

Post » Sat Mar 01, 2014 11:18 am

If you want points only once give enemy variable "givePoints" or so, boolean for example.

Code: Select all
Is boolean set
Enemy compare Y > Player.Y
Enemy compare X < Player.X

=>
Add points
Set givePoints false


If you level is not simple left to right then you could maybe compare distance and/or make some more coordinate checks.
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Wed Mar 05, 2014 2:02 pm

Thanks for your comment.
I try that and it somehow start counting the score.
However the score just keep running when ever I jump either over the enemy or not.
I did set the varible to add 10 to the varScore but what it does is just continue running the score until player touch the ground.
B
4
S
1
G
1
Posts: 6
Reputation: 842

Post » Wed Mar 05, 2014 2:05 pm

Also even I toggle disabled on set givePoints to false.
There seem to be no different at all.
B
4
S
1
G
1
Posts: 6
Reputation: 842

Post » Wed Mar 05, 2014 3:26 pm

Good question, here's something I knocked up quick...

I made it work both ways left to right or vice versa, let me know if it's what you need...

https://dl.dropboxusercontent.com/u/146 ... check.capx
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Wed Mar 05, 2014 4:50 pm

You could also pin a invisible sprite to the enemies (above them) and when the player collides with the invisible sprite then add to their score. You can have an instance variable on the invisible sprite that tracks if the player already collided with it so that you can keep them from getting more points jumping over the same enemy if you want.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Thu Mar 06, 2014 1:19 pm

@Pixel perfick
Thank you! I try your way and do some modify and it works :D
@ BluePhaze
That's an interesting way to count a score. Seem like there're a lot of way to get the work done.

Thanks you guy!
B
4
S
1
G
1
Posts: 6
Reputation: 842


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 62 guests