How do I change tiles based on what is near them?

Get help using Construct 2

Post » Fri Oct 10, 2014 6:03 pm

My issue is basically what is in the title. I am trying to get the tiles to check what is next to them and then update their frame based on whether there is ground near by, or not. I know that the events I currently have are likely not the most efficient, but that is not necessarily what I am going for at this moment. ( I am also using http://www.scirra.com/arcade/action/3926/go-faster as pretty much the ground work for this capx)

Currently what I do is spawn an air tile onto every ground tile that has an animation frame of 0, then I go through each Ground Object and check if it overlaps in Up, Down, Right, and Left directions. If it overlaps then we set the instance variable to true, and then go through a huge list of If Statements to determine which frame to set it to. (The green "grass" should be facing the air and just dirt should face nearby tiles.) Some tiles come up correct, and others do not. I feel that because of this I am missing something simple, so I am uploading the capx so you guys can get a better view of what I am rambling about. (I have to go to work so this is just being thrown up quickly :)
You do not have the required permissions to view the files attached to this post.
B
17
S
4
G
8
Posts: 23
Reputation: 4,886

Post » Fri Oct 10, 2014 7:14 pm

Here's a link one what that method is called:
http://www.saltgames.com/2010/a-bitwise ... -tilemaps/

Here is one way to do it with sprites:
viewtopic.php?f=147&t=72925&p=611090&hilit=bitwise#p611090

And here is an example using the tilemap object
span-class-posthilit-tilemap-span-auto-tile-help_p721581?#p721581
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sat Oct 11, 2014 3:06 am

@R0J0hound You are the greatest. Thank you so much, I read through the post and looked up your examples. (Part of the problem turned out to be my collision polygon.) I revamped from the massive true / false statements I had and simplified it down to the bitwise method. Again, thank you. Saved me some of my hair from being pulled out :)
B
17
S
4
G
8
Posts: 23
Reputation: 4,886


Return to How do I....?

Who is online

Users browsing this forum: DharmaOne and 18 guests