Page 1 of 1

Events that only happen in a certain area

PostPosted: Fri Sep 02, 2011 4:47 pm
by j2graves
Hi.
I'm trying to make an event where if the player actor is standing under a certain actor, and you press "J", a certain event will occur. let's call it "eventX". This would be a simple problem usually, but the thing is, The actor he's supposed to stand under is a tile actor. This makes things more difficult. If I use an event like,
if(player.x == tile.x)
{eventX;}

It won't work. It seems that only the first pixel of the first tile is set as the tile actor's x value.

What I want, is a script that allows eventX to occur when the player actor is under the tile actor, but that it will work on every tile, not just the first one.

Re: Events that only happen in a certain area

PostPosted: Fri Sep 02, 2011 8:54 pm
by skydereign
By under, do you mean in collision? If so, you can use getAllActorsInCollision in your keydown j event, or you can add a keydown j event to your collision event.
player -> Collision with tile (Repeat Enabled) -> Script Editor
Code: Select all
char* key = GetKeyState();
if(key[KEY_j]==1)
{
    eventX;
}


One thing to note, currently this event will trigger continuously, but you can use a variable to stop it. Another method, if nothing has a higher zdepth is to use getactor, but if the above example works, I'd probably stick with it.

Re: Events that only happen in a certain area

PostPosted: Fri Sep 02, 2011 8:56 pm
by SuperSonic
Try doing this (note: I'm not sure it will work on tiles though)

Code: Select all
if(Player.x >= Tile.x && Player.x <= Tile.x + Tile.width)
{
    Do_Event();
}


Tell me if it works please :P

Re: Events that only happen in a certain area

PostPosted: Fri Sep 02, 2011 8:58 pm
by skydereign
That won't work with tiles.

Re: Events that only happen in a certain area

PostPosted: Fri Sep 02, 2011 9:00 pm
by SuperSonic
That won't work with tiles


Darn :)

Sky knows everything haha :lol:

Re: Events that only happen in a certain area

PostPosted: Sat Sep 03, 2011 10:50 am
by j2graves
Thanks for the help, but I think I've solved the problem. I made an invisible actor which is basically a long vertical line, that has a collision and collisionfinish event, which I use to detect whether the player actor is under the tile or not.