Problems with Animated Tiles [SOLVED]

TylerMacLeod

  • Posts: 16
In a scenario where I use a Tile that has an animation in Scene1 and then load Scene2, if Scene2 has the same Tile, the animation dosent reset upon loading Scene2. So when I load an animated Tile in Scene2 that I had in Scene1 already, the Tile in Scene2 starts at the frame that the Tile in Scene1 left off at. (Rather than starting from the first frame in the animation.)

Are there any work arounds for this? Or is it just a property/setting that I have over-looked.

i.e. [set data for TileID: 1 TileSetID: 1 Frame:1]

« Last Edit: September 07, 2016, 11:59:34 am by TylerMacLeod »

Justin

  • *
  • Posts: 4446
This shouldn't be the case. What platform are you targeting?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)


Justin

  • *
  • Posts: 4446
Thanks, this is fixed in a private build now. To fix it in your own version of Stencyl without waiting for the next public release, go to [Stencyl install]/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx and find the following code.

Code: [Select]
for(tile in animatedTiles)
{
tile.currFrame = 0;
tile.currTime = 0;
}

Replace it with this.

Code: [Select]
for(tile in animatedTiles)
{
tile.currFrame = 0;
tile.currTime = 0;
tile.updateSource = true;
}

Here's the github commit, if it helps.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Wonderful! Thanks so much :D

TylerMacLeod

  • Posts: 16
After experimenting further, I believe the problem is not what I initially expected. It seems as though on Scene load, the animated Tiles play in the background. When they are "called" in the Scene, they have already played through.

Justin

  • *
  • Posts: 4446
What do you mean by being "called" in the scene? Are they off-screen when you first enter the scene?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
I have events that change Tiles. for example, when the user presses the F key, a tile at row 1 column 9 gets changed to a different tileID.

Justin

  • *
  • Posts: 4446
I see. If you want a tile to start from the first frame when it's added to the scene, you can do that with some code, but that code will make -every instance- of that tile go back to the first frame. So if you have your animated water or whatever appear at the bottom right, and then a second later you make that same tile appear at the bottom left, both instances of the tile would be reset to the first frame. Does that work for you?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

LIBERADO

  • *
  • Posts: 2704
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

TylerMacLeod

  • Posts: 16
That would work for me, yes. There is only ever 1 of the animated Tiles per scene so there would be no problem there.

Justin

  • *
  • Posts: 4446
In that case, you can do this at the same time that you use the set tile block.

Code: [Select]
var tile = (Data.get().resources.get(_tilesetID_) : Tileset).tiles[_tileID_];
//for example, (Data.get().resources.get(0) : Tileset).tiles[3];

tile.currFrame = 0;
tile.currTime = 0;
tile.updateSource = true;
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Events for 'Scene3': Type not found : Tileset
   from scripts.SceneEvents_3
   line: 101
   columns: 15-54

Justin

  • *
  • Posts: 4446
Add this in an import event in that behavior.

Code: [Select]
import com.stencyl.models.scene.Tileset;
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Events for 'Scene2': Unexpected import
   from scripts.SceneEvents_2
   line: 94
   columns: 0-6
Events for 'Scene2': Unexpected import
   from scripts.SceneEvents_2
   line: 94
   columns: 0-6