How to jump over enemies and get points?

Dracust

  • Posts: 4
Hey everyone,

I'm fairly new to Stencyl and so far i'm loving it.
But i've run to a small problem, or so i hope it is small.

I'm trying to build a platformer, but instead of having to jump over and hit enemies, like in super mario, i just want my hero to jump over them and be awarded some points.
I've tried using the comparison of x-positions like in the image attached, in a actor behaviour that i would attach to my hero, but unfortunately i get the errors in the second attached image.
I'm assuming the errors are due to the "Last Created Actor" in the condition, but i can't seem to find another option like a specific enemy.

Hope it's clear and that someone can help me.
Thanks in advance.

« Last Edit: October 08, 2016, 09:11:34 am by Dracust »

colburt187

  • *
  • Posts: 2416
Yeah unfortunately there are a few issues with this logic, the Last Created Actor is one, I don't think you could use that block for this purpose in any reliable way. the second issue is that the When Updating event triggers every frame, so your score would increase by 200, 60 times a second once there character was past the enemy.

I don't actually have a simple solution for this right now, you could maybe use regions placed behind the enemies, but that would depend if they are moving or not.

Dracust

  • Posts: 4
Yeah, the update every X seconds was a mistake, i removed it when i edited the post.
So, is there no way to compare the position between any 2 actors?

colburt187

  • *
  • Posts: 2416
It depends on your level set up I guess. If the enemies are already placed in the scene then you can reference from from the scene events, then you could use some bools to keep track of the points.

If actor1 jumped = false
if x of player is > enemy1
set score to score + 200
Set actor 1 jumped to true.

There is also a block called 'For each actor of type' that lets you reference actor types, but it might give you issues with multiple actors on the screen at once.

Dracust

  • Posts: 4
I'm sorry, but i have no idea how to convert any of the sample you gave me, into stencyl.
And yeah, i might have multiple enemies at the same time in the screen.

So, is there no way to specifically select an actor when comparing their positions?


Edit: I think i sort of solved it. I added 2 new attributes of the Actor type, which allowed me select the actors. Now i just need to find a way to only add the score once  :P

« Last Edit: October 08, 2016, 10:16:10 am by Dracust »

Pyschographics

  • Posts: 40
Hi, sorry was just browsing questions. Don't know if this is even a sensible offering, because it's not something I've needed to do, but just on the surface of it couldn't you divide the final score by the number of frames it takes? That was probably a really dumb thing to say, by someone who has no idea.