Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Question about animations - Gideros Forum

Question about animations

Hello!!, it's a noob question but... i just watch some examples with movie clip, but they use individual images for every frame, my question is... is there a way to use that class but with a sprite sheet? or i just have to do it in some other ways? thank you in advance :)

Likes: MoKaLux

+1 -1 (+1 / -0 ) Share on Facebook

Comments

  • Apollo14Apollo14 Member
    edited August 16
    @LostVGM Yes, sure. Check video below on texture packing.
    Basically, there're 4 ways to play animations:
    1) Old "MovieClip" class: http://docs.giderosmobile.com/reference/gideros/MovieClip#MovieClip
    2) New "Another MovieClip" (compatible with TNT Animator): http://forum.giderosmobile.com/discussion/7549/another-movie-clip
    3) @antix ' animation system (I've never tried it): http://forum.giderosmobile.com/discussion/comment/47115/
    4) Spine/Dragonbones skeletal animation.

    Likes: MoKaLux, LostVGM, antix

    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
    +1 -1 (+3 / -0 ) Share on Facebook
  • olegoleg Member
    edited August 16
     
    	-- construct a looping 6 frame animation where each frame is a different sprite
    	local mc = MovieClip.new{
    		{1, 1, frame1},	
    		{2, 2, frame2},	
    		{3, 3, frame3},	
    		{4, 4, frame4},	
    		{5, 5, frame5},	
    		{6, 6, frame6},
    	}
    	mc:setGotoAction(6, 1)	-- if the animation reaches frame 6 then go to frame 1
    mc :play()						
    -- construct a looping 6 frame animation playing 5 times slower than the previous example
    local mc = MovieClip.new{
    	{1, 5, frame1},	
    	{5, 10, frame2},	
    	{11, 15, frame3},	
    	{16, 20, frame4},	
    	{21, 25, frame5},	
    	{26, 30, frame6},
    }
    mc:setGotoAction(30, 1)	-- if the animation reaches frame 30 then go to frame 1
    mc :play()

    Likes: MoKaLux, LostVGM

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+2 / -0 ) Share on Facebook
  • @LostVGM it is a totally acceptable question, everyone was a beginner once upon a time don't worry.
    There is also one more way to do animation, it is through a class called "gtween.lua".
    You can do animation with only one sprite (image) and transforming this sprite like rotating , bouncing, pulsing, making biger smaller and on and on.. There are so many diffrent options inside the class you need to experiment it.
    (Just to give you an idea let us suppose there is a door closed on scene and you want to open it by clicking on it. You can apply gtween on the door image with rotation and maybe a little bit transformation with angle to gave the 3d effect to make it open.)

    In addition there is an example about gtween in the Gideros studio.

    Take care

    Likes: MoKaLux, LostVGM

    +1 -1 (+2 / -0 ) Share on Facebook
  • antixantix Member
    I wouldn't recommend GTween. Although it is a fantastic utility, if you have many animated objects it will impact performance in a seriously bad way.

    Not to toot my own horn but my system is fairly easy to mash into an existing codebase. It can be optimised a little but performance is pretty good.

    The drawback of everything mentioned besides Spine (and maybe TNT Animator) is that they are frame based. If your game starts to lag then the animations will become eratic as a result.

    Spine is fantastic but its not overly performant when many objects are being animated at once. @Apollo14 made a test somewhere and you can find it on the forums if you search :)

    Likes: LostVGM

    +1 -1 (+1 / -0 ) Share on Facebook
  • @LostVGM I have just uploaded a video showing how you can deal with sprite sheet animations. Hope that helps.


    Likes: LostVGM

    +1 -1 (+1 / -0 ) Share on Facebook
  • sorry for the late response :/, i have been very busy this days... Thank you for your responses, i used a spritesheet as i mentioned, and textureRegion class

    something like this:

    local frames = 1
    local duration = 0.07
    local totalTime = 0

    self.frames = {}
    self.frames[1] = TextureRegion.new(texture, 0, 0, 40, 40)
    self.frames[2] = TextureRegion.new(texture, 40, 0, 40, 40)
    self.frames[3] = TextureRegion.new(texture, 80, 0, 40, 40)
    self.frames[4] = TextureRegion.new(texture, 120, 0, 40, 40)

    then to update the frames:

    if self.movingR then
    totalTime = totalTime + dt

    if totalTime > duration then

    self:setTextureRegion(self.frames[frames])
    frames = frames + 1
    totalTime = 0
    end

    if frames > 4 then
    frames = 1
    end
    end

    it works but i'm not sure if something could be wrong, also i don't know how to post code like oleg xD, oh and i'm going to check your videos :), thank you again
  • @LostVGM hey I just uploaded a video where I use the same code as yours:

    self.frames = {}
    self.frames[1] = TextureRegion.new(texture, 0, 0, 40, 40)
    self.frames[2] = TextureRegion.new(texture, 40, 0, 40, 40)
    self.frames[3] = TextureRegion.new(texture, 80, 0, 40, 40)
    self.frames[4] = TextureRegion.new(texture, 120, 0, 40, 40)
    For the tile textures to make it more "professional". Have fun!

    Likes: LostVGM

    +1 -1 (+1 / -0 ) Share on Facebook
Sign In or Register to comment.