Difference between revisions of "MovieClip.new"

From GiderosMobile
(added see also)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Creates a new '''MovieClip''' object. After constructing the MovieClip object, it starts playing. You don't need to call [[MovieClip:play]].
 
Creates a new '''MovieClip''' object. After constructing the MovieClip object, it starts playing. You don't need to call [[MovieClip:play]].
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
MovieClip.new{timeline} -- *PLEASE NOTICE THE BRACKETS { } INSTEAD OF ( )*
 
MovieClip.new{timeline} -- *PLEASE NOTICE THE BRACKETS { } INSTEAD OF ( )*
 
</source>
 
</source>
Line 14: Line 14:
 
=== Example ===
 
=== Example ===
 
'''Frame animations'''
 
'''Frame animations'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
--load frames
 
--load frames
 
local frames = {}
 
local frames = {}

Revision as of 15:28, 13 July 2023

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. <syntaxhighlight lang="lua"> MovieClip.new{timeline} -- *PLEASE NOTICE THE BRACKETS { } INSTEAD OF ( )* </source>

Parameters

timeline: (table) array of timeline elements

Example

Frame animations <syntaxhighlight lang="lua"> --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) </source>

See also

Animated_Sprite_Factory