Difference between revisions of "MovieClip"

From GiderosMobile
m (formatting)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
 
<languages />
 
<languages />
 +
 
<!-- GIDEROSOBJ:MovieClip -->
 
<!-- GIDEROSOBJ:MovieClip -->
 +
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
 +
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
<translate><br />
+
<translate>
The [[Special:MyLanguage/MovieClip|MovieClip]] class inherits from the following classes: [[Special:MyLanguage/Sprite|Sprite]] > [[Special:MyLanguage/EventDispatcher|EventDispatcher]].<br />
+
The [[Special:MyLanguage/MovieClip|MovieClip]] class inherits from the following classes: [[Special:MyLanguage/Sprite|Sprite]] > [[Special:MyLanguage/EventDispatcher|EventDispatcher]].
<br />
+
<br/>
The [[Special:MyLanguage/MovieClip|MovieClip]] class is used create static timedlined animations. The timeline parameters are given as an array. <br />
+
 
Each array element specifies one timeline element and consists of the starting frame, ending frame, sprite and <br />
+
The [[Special:MyLanguage/MovieClip|MovieClip]] class is used create static timedlined animations. The timeline parameters are given as an array.
optional tweening parameters. Frame numbers start from 1.<br />
+
<br/>
<br />
+
 
When a [[Special:MyLanguage/MovieClip|MovieClip]] object finishes it playing (by reaching its final frame or a frame with stop action), <br />
+
Each array element specifies one timeline element and consists of the starting frame, ending frame, sprite and optional tweening parameters. Frame numbers start from 1.
it dispatches an [[Special:MyLanguage/Event.COMPLETE|Event.COMPLETE]] event.<br />
+
<br/>
<br />
+
 
The following properties can be tweened:<br />
+
When a [[Special:MyLanguage/MovieClip|MovieClip]] object finishes it playing (by reaching its final frame or a frame with stop action), it dispatches an [[Special:MyLanguage/Event.COMPLETE|Event.COMPLETE]] event.
<br />
+
<br/>
<ul>
+
 
<li>''x''</li>
+
The following properties can be tweened:
<li>''y''</li>
+
<br/>
<li>''rotation''</li>
+
 
<li>''scale''</li>
+
*''x''</li>
<li>''scaleX''</li>
+
*''y''</li>
<li>''scaleY''</li>
+
*''rotation''
<li>''alpha''</li>
+
*''scale''
</ul>
+
*''scaleX''
<br />
+
*''scaleY''
 +
*''alpha''
 +
<br/>
  
 
Additionally [[Special:MyLanguage/MovieClip|MovieClip]] uses set function to tween properties, so if you override provided object's set function by adding new parameters it can accept, then you can tween those new parameters too.
 
Additionally [[Special:MyLanguage/MovieClip|MovieClip]] uses set function to tween properties, so if you override provided object's set function by adding new parameters it can accept, then you can tween those new parameters too.
 +
<br/>
  
 +
The following easing functions can be used:
 +
<br/>
 +
 +
* ''"inBack"''
 +
* ''"outBack"''
 +
* ''"inOutBack"''
 +
* ''"inBounce"''
 +
* ''"outBounce"''
 +
* ''"inOutBounce"''
 +
* ''"inCircular"''
 +
* ''"outCircular"''
 +
* ''"inOutCircular"'
 +
* ''"inCubic"''
 +
* ''"outCubic"''
 +
* ''"inOutCubic"''
 +
* ''"inElastic"''
 +
* ''"outElastic"''
 +
* ''"inOutElastic"''
 +
* ''"inExponential"''
 +
* ''"outExponential"''
 +
* ''"inOutExponential"''
 +
* ''"linear"''
 +
* ''"inQuadratic"''
 +
* ''"outQuadratic"''
 +
* ''"inOutQuadratic"''
 +
* ''"inQuartic"''
 +
* ''"outQuartic"''
 +
* ''"inOutQuartic"''
 +
* ''"inQuintic"''
 +
* ''"outQuintic"''
 +
* ''"inOutQuintic"''
 +
* ''"inSine"''
 +
* ''"outSine"''
 +
* ''"inOutSine"''
 +
<br/>
 +
 +
Following examples demonstrates the possible uses of MovieClip class.
 +
<br/>
 +
</translate>
  
<br />
 
The following easing functions can be used:<br />
 
<br />
 
* ''"inBack"''<br />
 
* ''"outBack"''<br />
 
* ''"inOutBack"''<br />
 
* ''"inBounce"''<br />
 
* ''"outBounce"''<br />
 
* ''"inOutBounce"''<br />
 
* ''"inCircular"''<br />
 
* ''"outCircular"''<br />
 
* ''"inOutCircular"''<br />
 
* ''"inCubic"''<br />
 
* ''"outCubic"''<br />
 
* ''"inOutCubic"''<br />
 
* ''"inElastic"''<br />
 
* ''"outElastic"''<br />
 
* ''"inOutElastic"''<br />
 
* ''"inExponential"''<br />
 
* ''"outExponential"''<br />
 
* ''"inOutExponential"''<br />
 
* ''"linear"''<br />
 
* ''"inQuadratic"''<br />
 
* ''"outQuadratic"''<br />
 
* ''"inOutQuadratic"''<br />
 
* ''"inQuartic"''<br />
 
* ''"outQuartic"''<br />
 
* ''"inOutQuartic"''<br />
 
* ''"inQuintic"''<br />
 
* ''"outQuintic"''<br />
 
* ''"inOutQuintic"''<br />
 
* ''"inSine"''<br />
 
* ''"outSine"''<br />
 
* ''"inOutSine"''<br />
 
<br />
 
Following examples demonstrates the possible uses of MovieClip class.<br />
 
<br /></translate>
 
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
'''Example'''<br/>
+
'''Example'''
<source lang="lua">-- construct a 100 frame animation where x coordinate of sprite tweens from 0 to 200 linearly
+
<br/>
 +
 
 +
<source lang="lua">
 +
-- construct a 100 frame animation where x coordinate of sprite tweens from 0 to 200 linearly
 
local mc = MovieClip.new{
 
local mc = MovieClip.new{
 
{1, 100, sprite, {x = {0, 200, "linear"}}}
 
{1, 100, sprite, {x = {0, 200, "linear"}}}
Line 91: Line 103:
 
}
 
}
  
-- construct a looping 6 frame animation where each frame is a different sprite
+
-- construct a looping 6 frame animation where each frame is a different sprite
local mc = MovieClip.new{
+
local mc = MovieClip.new{
{1, 1, frame1},
+
{1, 1, frame1},
{2, 2, frame2},
+
{2, 2, frame2},
{3, 3, frame3},
+
{3, 3, frame3},
{4, 4, frame4},
+
{4, 4, frame4},
{5, 5, frame5},
+
{5, 5, frame5},
{6, 6, frame6},
+
{6, 6, frame6},
}
+
}
mc:setGotoAction(6, 1) -- if the animation reaches frame 6 then go to frame 1
+
mc:setGotoAction(6, 1) -- if the animation reaches frame 6 then go to frame 1
 
 
 
-- construct a looping 6 frame animation playing 5 times slower than the previous example
 
-- construct a looping 6 frame animation playing 5 times slower than the previous example
Line 111: Line 123:
 
{26, 30, frame6},
 
{26, 30, frame6},
 
}
 
}
mc:setGotoAction(30, 1) -- if the animation reaches frame 30 then go to frame 1</source>
+
mc:setGotoAction(30, 1) -- if the animation reaches frame 30 then go to frame 1
 +
</source>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 +
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
 
[[Special:MyLanguage/MovieClip.new|MovieClip.new]] ''<translate>creates a new MovieClip object</translate>''<br/><!-- GIDEROSMTD:MovieClip.new(timeline) creates a new MovieClip object -->
 
[[Special:MyLanguage/MovieClip.new|MovieClip.new]] ''<translate>creates a new MovieClip object</translate>''<br/><!-- GIDEROSMTD:MovieClip.new(timeline) creates a new MovieClip object -->
Line 125: Line 140:
 
[[Special:MyLanguage/MovieClip:setStopAction|MovieClip:setStopAction]] ''<translate>sets a &quot;stop&quot; action to the specified frame</translate>''<br/><!-- GIDEROSMTD:MovieClip:setStopAction(frame) sets a &quot;stop&quot; action to the specified frame -->
 
[[Special:MyLanguage/MovieClip:setStopAction|MovieClip:setStopAction]] ''<translate>sets a &quot;stop&quot; action to the specified frame</translate>''<br/><!-- GIDEROSMTD:MovieClip:setStopAction(frame) sets a &quot;stop&quot; action to the specified frame -->
 
[[Special:MyLanguage/MovieClip:stop|MovieClip:stop]] ''<translate>stops playing the movie clip</translate>''<br/><!-- GIDEROSMTD:MovieClip:stop() stops playing the movie clip -->
 
[[Special:MyLanguage/MovieClip:stop|MovieClip:stop]] ''<translate>stops playing the movie clip</translate>''<br/><!-- GIDEROSMTD:MovieClip:stop() stops playing the movie clip -->
 +
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===

Revision as of 11:26, 9 August 2019



Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: Sprite

Description

The MovieClip class inherits from the following classes: Sprite > EventDispatcher.

The MovieClip class is used create static timedlined animations. The timeline parameters are given as an array.

Each array element specifies one timeline element and consists of the starting frame, ending frame, sprite and optional tweening parameters. Frame numbers start from 1.

When a MovieClip object finishes it playing (by reaching its final frame or a frame with stop action), it dispatches an Event.COMPLETE event.

The following properties can be tweened:

  • x
  • y
  • rotation
  • scale
  • scaleX
  • scaleY
  • alpha


Additionally MovieClip uses set function to tween properties, so if you override provided object's set function by adding new parameters it can accept, then you can tween those new parameters too.

The following easing functions can be used:

  • "inBack"
  • "outBack"
  • "inOutBack"
  • "inBounce"
  • "outBounce"
  • "inOutBounce"
  • "inCircular"
  • "outCircular"
  • "inOutCircular"'
  • "inCubic"
  • "outCubic"
  • "inOutCubic"
  • "inElastic"
  • "outElastic"
  • "inOutElastic"
  • "inExponential"
  • "outExponential"
  • "inOutExponential"
  • "linear"
  • "inQuadratic"
  • "outQuadratic"
  • "inOutQuadratic"
  • "inQuartic"
  • "outQuartic"
  • "inOutQuartic"
  • "inQuintic"
  • "outQuintic"
  • "inOutQuintic"
  • "inSine"
  • "outSine"
  • "inOutSine"


Following examples demonstrates the possible uses of MovieClip class.

Examples

Example

-- construct a 100 frame animation where x coordinate of sprite tweens from 0 to 200 linearly
local mc = MovieClip.new{
	{1, 100, sprite, {x = {0, 200, "linear"}}}
}

-- construct a 100 frame animation where x coordinate of sprite is 50 (constant) and 
-- y coordinate of sprite tweens from 50 to 150 by using inBounce function
local mc = MovieClip.new{
	{1, 100, sprite, {x = 50, y = {50, 150, "inBounce"}}}
}

-- construct a 200 frame animation where sprite1 and sprite2 tweens differently
-- here sprite1 is visible between frames [1, 150]
-- and sprite2 is visible between frames [100, 200]
local mc = MovieClip.new{
	{1, 100, sprite1, {x = {0, 200, "linear"}}},
	{50, 150, sprite1, {y = {0, 100, "linear"}, alpha = {0, 1, "easeOut"}}},
	{100, 200, sprite2, {x = {0, 200, "linear"}}},
}

-- 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
						
-- 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

Methods

MovieClip.new creates a new MovieClip object
MovieClip:clearAction clears the action at the specified frame
MovieClip:getFrame
MovieClip:gotoAndPlay goes to the specified frame and starts playing
MovieClip:gotoAndStop goes to the specified frame and stops
MovieClip:play starts playing the movie clip
MovieClip:setGotoAction sets a "go to" action to the specified frame
MovieClip:setReverseAction sets a "reverse" action to the specified frame
MovieClip:setStopAction sets a "stop" action to the specified frame
MovieClip:stop stops playing the movie clip

Events

Event.COMPLETE

Constants