hi!
is possible to have little working example of using MovieClip ?
i want to replace all my sprite animation (with classic mode animation) with the use of MovieClip function
how to use them?
thanks and sorry for the request but (at least for me) the docs for MovieClip is not clear!
in the init function of my sprite i put
-- setup animations...
self.anim = {
Bitmap.new(pack:getTextureRegion("ucello1.png")),
Bitmap.new(pack:getTextureRegion("ucello2.png")),
Bitmap.new(pack:getTextureRegion("ucello3.png")),
Bitmap.new(pack:getTextureRegion("ucello4.png")),
}
mc = MovieClip.new{
{1, 1, self.anim[1]},
{2, 1, self.anim[2]},
{3, 1, self.anim[3]},
{4, 1, self.anim[4]},
{5, 1, self.anim[3]},
{6, 1, self.anim[2]},
{7, 1, self.anim[1]},
}
mc:setGotoAction(7, 1)
then in function birds:onEnterFrame()
i put
mc:play()
but no animation...
ciao
Gianluca.
Comments
1. MovieClip accepts start frame, end frame. So you should write:
mc = MovieClip.new{
{1, 2, self.anim[1]},
{2, 3, self.anim[2]},
{3, 4, self.anim[3]},
{4, 5, self.anim[4]},
{5, 6, self.anim[3]},
{6, 7, self.anim[2]},
{7, 8, self.anim[1]},
}
2. You need to call mc:play() once, not in enterFrame event.
:ar!
Likes: ilker
now i'm at work!!! when i go home i'll try!!!
thanks.!
www.tntengine.com
i replaced the code of my animation using movieclip... it's very handy and is a more convenient way to setup animations... (no code to control frame animations!)
in my elicopter code now i'm using...
self.anim = {
Bitmap.new(pack:getTextureRegion("eli1.png")),
Bitmap.new(pack:getTextureRegion("eli2.png"))
}
local eliAnim = MovieClip.new{
{1, 7, self.anim[1]},
{8, 15, self.anim[2]}
}
eliAnim:setGotoAction(15, 1)
self:addChild(eliAnim)
eliAnim:play()
and my elicopter fly!
but if i want to speedup (at runtime) the animation (ex when the player accelerate) how can i do?
can i use this method also for animate characters with no predefinited path ? (like the main player?)
i can set it's position with eliAnim:setPosition(x, y)
in theory movie clip is much more efficent for sprite animation than classic way (like "Texture pack" example) ?
sorry for my continuous questions!
thanks.
Gianluca
www.tntengine.com
Currently there is no way to set the animation speed. But you can prepare different animations for different speeds like:
Likes: atilim, SinisterSoft
Likes: atilim, SinisterSoft
www.tntengine.com
I think MovieClip needs 2 main improvements:
- adjusting speed
- dispatching events when it stops or reaches a specified frame
Can you think of another improvement?
>> MikeHart
>> I think MovieClip needs 2 main improvements:
>> - adjusting speed
>> - dispatching events when it stops or reaches a specified frame
yes i think it would be really useful B-)
www.tntengine.com
a DeltaTime? (yes i know i can implement my self but it is nice for a game sdk to have built in...)
www.tntengine.com
@GregBUG when the ENTER_FRAME event dispatches, the event object contains time and deltaTime:
Likes: plamen, hosamred
sorry useless question !
www.tntengine.com
www.tntengine.com
Likes: GregBUG, plamen, hosamred
current construction of movieclip has some limitations and flаws but it gives some unusual options. I'll give some example from my project. if you take a look to engines of the ships, the movieclip contains 2 sets of frames 1st for slow motion of the propellers and the second is for fast motion -->
local prop_t={}
for i=1,16 do
prop_t[i]=Bitmap.new(TextureRegion.new(ventilator_texture, 16*(i-1), 0, 16, 64))
prop_t[i]:setAnchorPoint(0.5,0.5)
prop_t[i]:setScale(0.5)
end
self.propeller= MovieClip.new{
{1, 1, prop_t[1]},
{2, 2, prop_t[2]},
{3, 3, prop_t[3]},
{4, 4, prop_t[4]},
{5, 5, prop_t[5]},
{6, 6, prop_t[6]},
{7, 7, prop_t[7]},
{8, 8, prop_t[8]},
{9, 9, prop_t[9]},
{10, 10, prop_t[10]},
{11, 11, prop_t[11]},
{12, 12, prop_t[12]},
{13, 13, prop_t[13]},
{14, 14, prop_t[14]},
{14, 15, prop_t[15]},
{16, 16, prop_t[16]},
}
self.propeller:setStopAction(10)
self.propeller:GotoAndPlay(1)
self.propeller:addEventListener("complete", self.onMovieComplete,self)
frames 1-10 are for slow motion and 11 to 16 are for fast motion
when i need them to run fast i do:
self.propeller:setStopAction(16)
self.propeller:GotoAndPlay(11)
i use event handler for my logic code to decide swapping the two sets
Also this construction gives you the option to animate lots of parameters and do tweens. Its very flexible but some how not very intuitive. It just needs more examples and it will be fine. First i was shocked about how different is from other frameworks but after two month extensive use i love it.
local propeller_bmp = Bitmap.new(propeller_A_texture)
propeller_bmp:setAnchorPoint(0.5,0.5 )
self.propeller=MovieClip.new{
{1, 100, propeller_bmp,{rotation={0,360,"linear"}}}
}
self.propeller:setGotoAction(100,2)
This one just rotates single bitmap.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
My TNT Animator is based over it.
maybe you can try it.
Likes: riyann68
www.tntengine.com
And yes, try out the TNT Animator, it would really ease things up.
Also @plamen's example is a great one. It's possible to put multiple animations into one MovieClip and separate them by using setStopAction function.