Pick tile in array and change frame

0 favourites
  • 11 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I'm creating a 2D-Minecraft like game as a test and I'm a little stuck on this, the code below should change all tiles to frame 3 (a grey tile) but instead they all stay at frame 1. Why is that?

    <img src="http://i.imgur.com/aLXGV.png" border="0" />

  • Actually, that should have worked, my guess is that it may need a tick to change the value,.... but you don't need to compare anything any way.

    When you create the sprite, its already picked. So just drag the "Set animation frame 3" action up under the y loop.

  • Hm, well the reason for the seperate pick is for future code to come. If I drag "Set animation frame 3" to the Y loop it works, but when I set 3 to be the actual array entry it doesn't work!

  • It may be a bug. Might make a capx to confirm.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • +System: For "groundX" from 0 to worldWidth
      Local variable pickUID=-1
      +System: For "groundY" from 0 to worldHeight
        ->System: create object item on layer 0 at......
        ->worldArray: set value at (loopindex("groundX"),loopindex("groundY") to 1
        ->System: set pickUID to item.UID
      +worldArray: value at(loopindex("groundX"),loopindex("groundY") = 1
      +item: pick instance by UID pickUID
        -> item:set animation to 3

    Two remarks:

    1/ As far as I know, the item created is picked only in the action block in which it is created. In the next event only the picking by condition is used.

    2/ 'Current value' as well as 'Current X', 'Current Y' and 'Current Z' should only be used in an 'Array foreach element' loop. That's what the "current" is about.

  • Supposedly its the top tier that picks, and sub events to the creation tier should remain picked. So even though this is a sub event, its is the top tier as far as the tile being picked/ created is concerned.

    It must be the array, its either not being initialized correctly, or possibly a non integer issue.

    Edit:

    Ahh didn't see the current for array, yeah don't use that with a loop.

  • Hm, right...well what's the solution I'm looking for then to achieve the same effect?

  • Didn't you try what I wrote ?

  • Oh sorry, didn't notice you posted fixed code (just thought you'd put my code in text rather than a screen!). Just tried it but nothing I'm affraid...

    <img src="http://i.imgur.com/rt9sd.png" border="0" />

  • nest the 4th event under the 3rd event

  • Still nothing I'm afraid :(

    <img src="http://i.imgur.com/eEmmj.png" border="0" />

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