What's your preferred method of animating tiles?

0 favourites
  • 7 posts
From the Asset Store
40 Seamless textures for tile backgrounds. High resolution 1024x1024!
  • Just looking to get a discussion going so maybe I find out better ideas than what I did.

    Currently I just made a function with a target tile and new tile parameter with the tile ID numbers respectively that changes them with a replace() expression on the tilemap as a JSON string. It's definitely waaaaaay less intensive than using a for loop to check even just every tile on screen. Then I use the timer behavior and internal numeric variables to control individual tile anims.

  • This is what my function looks like. It's somewhat hard to parse visually due to how tilemap data is stored so it will replace the specified tile right, but it is way better than the for loop method as said even with it replacing every single instance in the whole tilemap.

  • Animating tiles sounds nice. Your method looks clever as well, I didn't know you could that!

    Let's hope Construct would support animating tiles in the future; e.g. letting us use frames in the tilemap editor. Otherwise, all our solutions will remain "hacky", in a way.

    Let's say you are going to animate multiple tiles every frame, instead of replacing each tile, wouldn't it be easier to build a JSON string for the whole map in each frame, and use it to replace the whole map every frame?

    Example: TMjsonFrame[0], TMjsonFrame[1],...TMjsonFrame[X] (built at Layout start or hardcoded during design)

    Every Tick: Tilemap = TMjsonFrame[N]; N=(N+1) mod (X+1);

    Also, I think scripting is worth a try, maybe it has easier access to the internals of the tilemap.

    Oh, and speaking of tilemap forloops, here is a suggestion that will make them less painful. It has been 3 years already and still "No status" :'(

    construct3.ideas.aha.io/ideas/C3-I-351

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, how nice! I was missing around and found TileMap:Load from URI. Using a couple of png files, I could change the tilemap frames.

  • Well, how nice! I was missing around and found TileMap:Load from URI. Using a couple of png files, I could change the tilemap frames.

    This is awesome! Bless you for sharing this

  • This is awesome! Bless you for sharing this

    ^_^

  • Those are viable methods too if I understood correctly. Though they have drawbacks compared to what I did, I will definitely keep in mind your one method to load the tilemap data as a whole manually, because that would allow for more intricate animations than what I did. The method to load a new tilemap image also could be handy for an entire tilemap animating every tile at the same speed.

    Mine just basically gets rid of the need for an entire image for each frame of the tilemap so you won't have redundant repeats of the same graphic for tiles that are static. Also allows for different tiles to animate at different speeds. The downside is that the replace() expression could hypothetically conflict and seriously mess up the tilemap, displacing tiles and all kinds of nasty things you'd probably never want. lol

    Hopefully in the future Ashley makes it where we can do animation frames on a per-tile basis. Obviously it's not essential because we have three very feasible work arounds to animating tiles despite C3 has no built in tile animation. Just would streamline the process and probably require less processing than what we're doing. I see he did things like being able to turn off tile collisions. Also would be cool if he added some functionality like Tiled has, such as tile properties, so we can do some really complex stuff just with the tilemap alone without needing separate objects like detectors.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)