Tilemap background effect on mouse hover

0 favourites
  • 3 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hey Guys, I'm trying to set up a background effect with a tilemap but i cant seem to figure it out,

    I basically just want that when the mouse hovers over the tiles, the tiles would change to the second tile, then when the mouse is not over them, there will be a short delay before they change back to the first tile.

    the way i set it up is almost right except the tiles change back all at the same time instead of one at a time.

    any advice would really be appreciated, i've been trying to figure it out for a while.

    Here is my current code:

    // Spawn Initial Tiles

    + System: On start of layout

    -> System: Set layout scale to 2

    ----+ System: For "X" from 0 to 216

    --------+ System: For "Y" from 0 to 192

    ---------> Tilemap: Set tile (LoopIndex("X"), LoopIndex("Y")) to tile floor(random(2))-1 (normal)

    // Cell State Management

    + Mouse: On movement

    -> (no actions)

    + Tilemap: Tile (Tilemap.PositionToTileX(Mouse.X), Tilemap.PositionToTileY(Mouse.Y)) = 0

    -> Tilemap: Set tiles at (Tilemap.PositionToTileX(Mouse.X), Tilemap.PositionToTileY(Mouse.Y)) with area 1 x 1 to tile 1 (normal)

    // Revert Tiles Back to 0

    + System: Every 0.55 seconds

    ----+ System: For "X" from 0 to 216

    --------+ System: For "Y" from 0 to 192

    --------+ Tilemap: Tile (LoopIndex("X"), LoopIndex("Y")) ≥ 1

    ---------> Tilemap: Set tiles at (LoopIndex("X"), LoopIndex("Y")) with area 1 x 1 to tile 0 (normal)

  • Loops are executed in 1 tick. So all of the tiles that are changed will be changed back every 0.55 sec. I think you need some kind of queue to store the tiles in an order and set them back tile for tile.

    I made a litte example:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks man, i think you definitely have the right idea, ill give it a try :)

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