Author Topic: animated tiles  (Read 6295 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
animated tiles
« on: 2007-11-27, 06:41:07 AM »
my problem is a little bit different from that in jams thread back in march, and since his thread is very old...

i made an animated tile with the tileset editor, and in the preview window it works fine. but the tile is not animated when i add it to the layer.
do i have to create some "anim tile definition"?
could the problem be that i made my tileset bigger to draw the needed tiles into it, long after i used it to create the layer? (i added the new tiles properly to the frameset and tileset, though)

i go and try it with a new graphic sheet...
edit: no, that won't work.  i used a older but unused graphic sheet, and made the same animation. but without success in animating it in a new layer.
even with a completely new graphic sheet it won't work. so, it must be scripted anywhere?
« Last Edit: 2007-11-27, 06:59:22 AM by Morgengrauen »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #1 on: 2007-11-27, 07:48:59 AM »
If the tile is animated in the Tileset preview, but not when you run the game, it probably means you didn't make a rule to increase the counter associated with the tile.  The counter does not increase automatically.  Your rules are totally in charge of when the counter changes.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #2 on: 2007-11-27, 07:53:47 AM »
indeed i hadn't a rule for that. i'll try to make one.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #3 on: 2007-11-27, 01:18:49 PM »
it works. hooray!
depends a counter always on the frame rate? how can i prevent things playing faster or slower at different computers?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #4 on: 2007-11-28, 07:21:29 AM »
I have not implemented built-in support for time-based animation in version 2.0, but I might improve that for 2.1.  However, you can implement your own time-based features.  For example, instead of incrementing the counter every frame, you could set it to be equal to the number of tenths of seconds since the beginning of today with some expression like this (using the "=" function output to Counter.CurrentValue):
Code: [Select]
(int)(System.DateTime.Now.Subtract(System.DateTime.Today).TotalSeconds * 10)(Not sure if that's exactly correct, but hopefully it's close.)

Be careful how you set the maximum counter value.  Make sure it's big enough to hold the number of seconds in a day * 10. (10*60*60*24=864000)
See information about System.DateTime.Subtract here:
http://msdn2.microsoft.com/en-us/library/8ysw4sby.aspx

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #5 on: 2007-11-28, 07:42:14 AM »
Argument '2': cannot convert from 'int' to 'CounterOperation'

you have written (int) before that other stuff. i often get the message a "double" or other values (?) couldn't be converted to an "int". is there a list of what conversions work? and what the meaning of int, double, ref and so on is. how and where they are used.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #6 on: 2007-11-28, 07:51:12 AM »
The "=" function does not take a CounterOperation parameter. Are you sure you selected the right function?  I have to go to work, so I can't explain conversions in more detail right now, but hopefully this will help.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #7 on: 2007-11-28, 08:23:42 AM »
(using the "=" function output to Counter.CurrentValue)

sorry, my fault. first it didn't work, but then i realized MY counter is not given in the expression. so i wrote: Counter.New_Counter_1.CurrentValue ;D
hooray!

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #8 on: 2007-12-17, 03:53:20 PM »
I have not implemented built-in support for time-based animation in version 2.0, but I might improve that for 2.1.

please do so!
i would need it. the counter you have shown me counts constantly, but its value changes the whole day, and i don't know how to make it count a timespan like 5 seconds.

edit:
but because animated tiles are involved, i could perhaps do a trick, couldn't i? i let do a tile animation based on your counter. and when the tile animation reaches a certain frame, i have got my 5 seconds! gotta try that....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #9 on: 2007-12-17, 05:28:57 PM »
Using a timer for a counter value on an animation that doesn't loop won't work well because the counter won't start at 0, so the animation won't start on the first frame.  I don't understand how you could have a tile that should only animate for 5 second, though.  What kind of tile only animates for 5 seconds?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #10 on: 2007-12-18, 03:30:31 AM »
i wanted to make the snowstorm with it. when the player touches a plan rectangle, a snowstorm map will be set for overlay. the snowstorm is supposed to last for 5 seconds. the snowstorm tiles shall be animated. i thougt i could make an animation for these tiles, and at the end of the five seconds they vanish into thin air (animation drawn by me). at his point the five seconds are over and the overlay map can disappear.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #11 on: 2007-12-18, 08:12:40 AM »
Oh, then it doesn't matter where the animation begins or ends, just that it lasts 5 seconds.  Maybe when the snowstorm is triggered you could use the "=" function to copy the value of the timer counter to another counter and add 50 (5 seconds in tenth-of-second counter units).  Like
Function: =
Value: 50+StormCounter.CurrentValue
Output: TimerCounter.CurrentValue

Then have another rule to check when TimerCounter >= StormCounter, and when true, clear the overlay map.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #12 on: 2007-12-18, 01:39:04 PM »
fine, i got the same idea as you, with this counter value + number of custom frames.
this should work.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animated tiles
« Reply #13 on: 2008-01-08, 08:20:40 AM »
is the frame number of a tile animation always equal to the actual value of its counter?

Oh, then it doesn't matter where the animation begins or ends, just that it lasts 5 seconds.

because it does matters, the storm has an end and a beginning.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: animated tiles
« Reply #14 on: 2008-01-08, 08:45:05 PM »
is the frame number of a tile animation always equal to the actual value of its counter?
Yes, with a couple notes:
1. Don't forget about the repeat count.  If the repeat count of all your frames is 10, and the counter value is 15, then you will only be looking at the second distinct frame.
2. The animation loops, of course, so if you have 3 frames (each with repeat count of 10), then when the counter value is 35, you will be looking at the first frame again, and when it is 45, you will be looking at the second frame again.