Detecting what tile under sprite

Get help using Construct 2

Post » Sun Jul 22, 2012 4:52 am

I'm practicing on making a platformer. right now trying to make enemy that patrols back and forth over bunch of tiles. think of it like Mario's enemies how they go back and forth. for that i need to detect if the enemy is about to reach the end of the tiles so then it can reverse its direction.   How do I achieve this? I tried to search the forum, but may be I didn't use right terms.

I tried using specific tile x and width, I was able to make it reverse direction on reaching the start, but reaching the end I couldn't because as far as i can see there is no way to detect how many tiles arranged in that area to calculate the end of that particular platform.

I tried using sin movement, but then this will be a problem since platforms are not equal in length.   also I didn't find a way to detect in what direction that movement of the sin is going into so that I can mirror the sprite.

In sum: How to detect what tile/sprite/object exist in specific x y?
thanks
B
8
S
2
G
3
Posts: 15
Reputation: 2,749

Post » Sun Jul 22, 2012 5:25 am

I thought now of different approach, by having invisible walls for enemies if on collision reverse direction. still if someone knows how to detect what object on x,y, please share. thanks
B
8
S
2
G
3
Posts: 15
Reputation: 2,749

Post » Sun Jul 22, 2012 5:48 am

You can achieve this by using "Is overlapping at offset".

Here's an example I whipped up.

Example .capx

Basically just checks if there is a floor a certain distance to the right or left depending on the direction it's moving and then changes directions accordingly.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sun Jul 22, 2012 5:53 am

Thanks a lot! that exactly what I was looking for.
B
8
S
2
G
3
Posts: 15
Reputation: 2,749

Post » Sun Jul 22, 2012 6:01 am

No problem :)

Here's a 2 event version using ternary operation. I'm bored ^^;

Example2 .capx
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sun Jul 22, 2012 10:05 am

thanks Tokinsom, unfortunately, I can't view the file because it says different version, I need to download the beta. I ll do that today and have a look. thanks (; I appreciate it.
B
8
S
2
G
3
Posts: 15
Reputation: 2,749


Return to How do I....?

Who is online

Users browsing this forum: Artpunk and 16 guests