Change frame for top most tile

Get help using Construct 2

Post » Wed Jul 17, 2013 2:59 am

So we are using a random tile generator, and we would like to make it so that if a tile is the top most tile, it will display a different animation frame to support it being the top tile, instead of the middle tile. Same with bottom and sides. Is there any good non performance crushing way to do this?
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Wed Jul 17, 2013 10:32 am

In the sprite conditions, you have a specific one for the Z-order : pick top/bottom. This will, giving a current selection of those sprites, filter only the top or bottom instance, for you to change its frame.
screenshot
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Wed Jul 17, 2013 2:52 pm

This would work if the tiles were overlapping each other, but I'm talking about if the tile is one block higher than the other blocks. Like check out sdiqs game, we are using his random generation. When given a texture, the top most blocks (ones higher on the Y axis) for a given block group will have a different texture

http://www.scirra.com/arcade/addicting-action-games/3926/go-faste
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Wed Jul 17, 2013 3:08 pm

To check if a tile is a 'topmost' tile, check if there is a tile directly above it. If not, then change it's frame.

This could be done using 'Overlapping at Offset':[code]is 'Tile' overlapping 'Tile' at offset (0,-1)'[/code]This will move the 'Tile' up a pixel and test for overlap. Inverting this condition will effectively test whether it's the topmost tile or not.

For bottom and sides use offsets (0, 1), (-1, 0), (1, 0) respectively.

EDIT:
If you can figure out (roughly) how your tiling engine works, the best approach would be to tap into its array to figure out if there's a tile above the one you are testing. That would be the easiest and the most straightforward.Dalal2013-07-17 15:29:51
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Wed Jul 17, 2013 7:57 pm

What if we have collisions disabled for all tiles unless they are within a given range of the player? This is to save performance. Then they won't know if they are overlapping or not right?
(done at events 1-3 on Event1Sheet)

https://www.dropbox.com/s/qisgitsycn56t5y/Check%20Tile%20Overlap.capx
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Wed Jul 17, 2013 10:08 pm

Yeah it won't know. I can't check the .capx from here (restrictions at work), but why don't you try to peer into the array if you can? That would be the best approach.

If that ends up being difficult to do, you could enable all collisions momentarily before doing the check. After the check you can disable the collisions again. In fact, if your tiles are static, you should do it on Start of Layout. Then you only have to do it once.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Thu Jul 18, 2013 3:35 am

The problem is C2 can't compare an object against it's own type. You need an invisible clone to position appropriately, and then do any tests. This isn't pretty, but...

Check Tile Overlap_BHT.capx
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672

Post » Thu Jul 18, 2013 4:43 am

oh wow! that gets the job done, but it definitely crushes performance.   And since the game is set out to be a mobile game, it might not be the best solution. But you used some very interesting conditions that ive never even heard of! problem is also, that we already have way too many objects for mobile, and this just creates more.

It's proving troublesome for us to do the random gen, as well as reduce the collisions, as well as change the animation frames of tiles per level (to change the color up) as well as change the type of tile (top tile, bottom tile, side). It seems that there is no good way to do this without ending up with crushing performance.
B
35
S
5
Posts: 411
Reputation: 3,406


Return to How do I....?

Who is online

Users browsing this forum: Mallets, R0J0hound, Ryan Kocourek and 13 guests