Results 1 to 2 of 2

Thread: question about sprite animation

  1. #1
    Squire
    Join Date
    Mar 2011
    Location
    South Korea
    Posts
    14

    Default question about sprite animation

    How Could I ainmate multiple line sprite like this?
    Name:  sprites.png
Views: 14
Size:  88.5 KB
    I found a function(AnimateEntity) that support only one line sprites.

    And one more question.
    AnimateEntity has animSpeedMS arg.
    Are There any method to set up the every single frame time?

    Thanks in advance.

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,369

    Default

    Hmm, you're right. AnimateEntity assumes the anim is a single line, either horizontal or vertical.

    Here is a way to play the whole grid, and also get per-frame ms timing. It schedules every frame to play in advance.

    //untested code...

    Code:
    void AnimateOneLoop(Entity *pEnt)
    {
    	EntityComponent *pComp = pEnt->GetComponentByName("OverlayRender");
    	
    int framesX = pComp->GetVar("totalFramesX")->GetUINT32();
    int framesY = pComp->GetVar("totalFramesX")->GetUINT32();
    
    int delayMS = 100; //100 ms per frame
    int ms = 0;
    
    for (int y=0; y < framesY; y++)
        for (int x=0; x <framesX; x++)
      {
            ms += delayMS; //speed can change to anything here, so you have per frame control
            GetMessageManager()->SetComponentVariable(pComp, ms, "frameX", Variant(uint32(x)));
    	GetMessageManager()->SetComponentVariable(pComp, ms, "frameY", Variant(uint32(y)));
            x++;
          
       }
      y++;
    
    }
     
    }
    
    //load the image in a RenderOverlayComponent
    Entity *pEnt = CreateOverlayEntity(pParent, "myEnt", "media/donut.png");
    
    //tell the component about the grid dimensions so it will draw frames
    SetupAnimEntity(pEntity, 5, 6); //because the image is 5 X 6
    AnimateOneLoop(pEntity); //play through the anim once
    So that would play the anim once. You could schedule it to run another AnimateOneLoop at the end to keep looping.

    If you need more fancy controls or want to have hundreds of these like, for a game, I'd probably just try to use a SurfaceAnim directly. (could throw it in a Component or just use it raw from something else)

    PS: I totally recognize that image from waaaay back when I was learning DirectX 5 for Dink.. haha.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Animation help
    By palmier in forum Novashell Game Creation System
    Replies: 0
    Last Post: 09-08-2010, 10:43 AM
  2. Sprite Animation and Checking Collisions
    By Solitude in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-10-2009, 12:27 PM
  3. Cursor and Sprite question.
    By Eng C. Born in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 04-18-2009, 02:05 PM
  4. sprite question?
    By Mahdi in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 09-07-2008, 12:18 PM
  5. Simple Animation
    By ares in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 02-27-2008, 05:20 AM

Bookmarks

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
  •