Results 1 to 3 of 3

Thread: Sprite Animation Backwards ... possible?

  1. #1

    Sprite Animation Backwards ... possible?

    Hello Everyone,

    My next problem is (cause I'm trying to not waste more memory then needed for images) is this , I have a rotating moon, that turns to you, then Yawns...and turns back... waits for a bit and does this again.

    Currently I'm doing it like this :

    Code:
    Case round(Moon.AnimPos) of
          0..71 : Moon.AnimSpeed:=20;
          72..85 : Moon.AnimSpeed:=10;
          86..155 : Moon.AnimSpeed:=20;
          156 :
            begin
              Moon.AnimStart:=156;
              Moon.AnimStop:=156;
              Counter:=Counter+1;
              if Counter = 400 then
                begin
                  Moon.AnimStart:=0;
                  Moon.AnimStop:=156;
                  Moon.AnimPos:=0;
    Counter:=0;
                end;
            end;
        end;
    The problem is that 86..155 should not be there... it's exactly the same as 0..71 but only in reverse... I could not figure out how can I move a Sprite Animation backwards ... tried the obvious...by setting sSprite.AnimStart:=71 , AnimStop:=0 but does not work...

    1. Is this solvable?
    2. I thought about it that maybe I'm completely wrong here... and the SpriteEngine is only supposed to go trough images in one direction and that is only forward and not backwards.


    Thanks
    Rob
    Last edited by WILL; 02-08-2011 at 11:32 PM. Reason: Please use proper code blocks...

  2. #2
    I would do it with sine-wave, because it makes smooth moves.

    Hope these bits help, its not ready code so you would have to adapt it:
    Code:
    const ToRad = 0.0174532925199433;  //  PI / 180 = Deg To Rad
    ...
    Counter:=(Counter+1) mod 360;
    Moon.AnimPos:=72+72*sin(Counter*ToRad);

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Hi Robert, welcome to PGD.

    I'd like to ask you to please put your code into proper code blocks so it's easier to read in the forums. Thanks.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL