Events that only happen in a certain area

Non-platform specific questions.

Events that only happen in a certain area

Postby j2graves » Fri Sep 02, 2011 4:47 pm

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.
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Events that only happen in a certain area

Postby skydereign » Fri Sep 02, 2011 8:54 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Events that only happen in a certain area

Postby SuperSonic » Fri Sep 02, 2011 8:56 pm

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
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Events that only happen in a certain area

Postby skydereign » Fri Sep 02, 2011 8:58 pm

That won't work with tiles.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Events that only happen in a certain area

Postby SuperSonic » Fri Sep 02, 2011 9:00 pm

That won't work with tiles


Darn :)

Sky knows everything haha :lol:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Events that only happen in a certain area

Postby j2graves » Sat Sep 03, 2011 10:50 am

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.
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest