It looks like you're new here. If you want to get involved, click one of these buttons!
local texture = Texture.new("images/spinner.png") local bitmaps = {} for i=1, 19 do bitmaps[#bitmaps] = {i, i, Bitmap.new(TextureRegion.new(texture, 0, (i-1)*108, 108, 108))} end local mc = MovieClip.new({ bitmaps }) mc:setGotoAction(19, 1) mc:setAnchorPoint(0.5, 0.5); mc:setPosition(conf.width/2, conf.height/2) self:addChild(mc) |
Comments
You should do something like that:
1, 100
101, 200,
201, 300
etc
you can adjust the speed of animation by changing value of len variable
Likes: antix
Sorry, I should have been more specific. Right now my code is erroring out on this line
So now it is loading and I just get a still image. What I would like to do is have it play and loop "forever" until I hit some condition (I'm using this as a loading indicator).
This is what I currently have, but it just displays one image doesn't animate at all. The code resides inside a Scene init function.
Thanks that does work. In this case I don't really understand why it works though. Any chance you could explain what is happening?
So at first you define a goto action, meaning when it reaches specific frame it jumps to other frame.
In your case when it reaches last frame it jumps to first frame, thus loopin whole animations.
You can also define stop actions too. by stopping animation when reaching specific frame.
or you can clear the frame from any action.
and gotoAndPlay just goes to provided frame and starts playing your animation, which upon reaching last frame jumps back to first one to start again.
Of course since it is first frame, you could simply call play and I think it would play from first frame too.
http://docs.giderosmobile.com/reference/gideros/MovieClip#MovieClip
Likes: bigtunacan
Thanks. That makes sense. I was thinking the play function and the gotoAndPlay function should work the same way if I just wanted to loop from the first frame. I think my confusion was I mistakenly thought this was where I had messed up, but the issue was with where I was misusing setGotoAction.
Thanks again!