Author Topic: animate sprite frames backwards?  (Read 4611 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
animate sprite frames backwards?
« on: 2007-12-03, 01:31:12 PM »
if i made one animation, and wanted it to be played normal but also in reversed direction, downcounting the frames, is that possible?
i tried this:
frame = 35
SpriteBase.SpriteAnimationType.ByFrame-1
but i didn't work. an if-condition was set, when i remove the -1 it works.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animate sprite frames backwards?
« Reply #1 on: 2007-12-03, 01:37:21 PM »
hm, main problem seems to be the frame = 35 before beginning the animation... why?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: animate sprite frames backwards?
« Reply #2 on: 2007-12-03, 01:40:02 PM »
the Animation function takes a SpriteAnimationType and deals with it by itself.  The ByFrame type tells Animation function to increase frame by 1 every time it's called.  You can't subtract 1 from a SpriteAnimationType, that's like trying to find the answer to 10 + orange.  Instead, if you are indeed animating by frame, the simplest method of animation, that can generally be replaced with a different type of function:
Code: [Select]
Type: Do
Function: +
Input 1: frame
Input 2: 1
Output: frame
This is generally the same thing.  If you change the function to - it will animate backwards instead of forwards.  Or you could change the 1 to a -1 for the same effect without having to change the function.  I don't know if it will work correctly if frame is negative, though.  You'd have to do a bit of work to make sure it didn't go negative if it doesn't work when frame < 0.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: animate sprite frames backwards?
« Reply #3 on: 2007-12-03, 01:57:04 PM »
thank you very much, it works!  :D
and when the frame gets 0, a fatal error occurs. but that is fine, one can prevent that.