Difference between revisions of "MovieClip.new"
From GiderosMobile
(added example) |
(added see also) |
||
Line 55: | Line 55: | ||
stage:addChild(ballAnimation) | stage:addChild(ballAnimation) | ||
</source> | </source> | ||
+ | |||
+ | === See also === | ||
+ | '''[[Animated_Sprite_Factory]]''' | ||
{{MovieClip}} | {{MovieClip}} |
Revision as of 01:04, 13 April 2022
Available since: Gideros 2011.6
Class: MovieClip
Description
Creates a new MovieClip object. After constructing the MovieClip object, it starts playing. You don't need to call MovieClip:play.
MovieClip.new{timeline} -- *PLEASE NOTICE THE BRACKETS { } INSTEAD OF ( )*
Parameters
timeline: (table) array of timeline elements
Example
Frame animations
--load frames
local frames = {}
local bmp
for i = 1, 6 do
bmp = Bitmap.new(Texture.new("animation/ball"..i..".png", true))
bmp:setAnchorPoint(0.5, 0.5)
frames[#frames+1] = bmp
end
--arrange frames
local ballAnimation = MovieClip.new{
{1, 5, frames[1]},
{6, 10, frames[2]},
{11, 15, frames[3]},
{16, 20, frames[4]},
{21, 25, frames[5]},
{26, 30, frames[4]},
{31, 35, frames[6]},
{36, 40, frames[4]},
{41, 45, frames[5]},
{46, 50, frames[4]},
{51, 55, frames[6]},
{56, 60, frames[4]},
{61, 65, frames[5]},
{66, 70, frames[4]},
{71, 75, frames[6]},
{76, 80, frames[3]},
{81, 85, frames[2]},
{86, 150, frames[1]}
}
--loop animation
ballAnimation:setGotoAction(150, 1)
--start playing
ballAnimation:gotoAndPlay(1)
ballAnimation:setPosition(160, 240)
stage:addChild(ballAnimation)
See also