Hey all. I am trying to decide if I should use MovieClip for animations, or if I should just create my own animation system. I have looked at some MovieClip examples and tutorials but I'm slightly confused and wonder if somebody can answer a question. Is every frame in a MovieClip a separate Bitmap and each of those bitmaps a separate image file?
EDIT:Well here is my Animation Editor. It's purpose is to create animation data for sprites arranged in a grid, inside a TextureAtlas.
HOWTO - EDITOR:To get started quickly, load an atlas (player.png in the images folder should do), load an animation file (player.aaf in the images folder will suffice), and start messing about. Otherwise...
1. Click the "Load" toolbar button in the :TextureAtlas" pane to load an atlas. By default your atlas will be sliced vertically into 64x64 sized regions, which you will see populating the "TextureRegions" pane, ready to be added as frames in your animations. You can change the slice settings at any time and click the "Vertical" or Horizontal" buttons to reslice the atlas.
2. Select an animation from the list in the "Animations" pane. You can rename it and set it's other properties with the controls in the Animation pane.
2a. Click the "Loops" checkbox if you want the animation to loop when complete.
2b. Use the "Speed" slider to adjust playback speed. The formula for animation playback speed is as follows... (1 / number of frames) * playback speed.
2c. Use the "offsetX" and "offsetY" sliders to adjust the frames position.
NOTE: This information is saved but the Animator class currently ignores these values.
3. To add frames to an animation just "DoubleClick" any region in the "TextureRegion" pane and it will be added to the currently selected animations list of frames (in the "Frames" pane).
4. You can use the controls in the "Frames" pane to move the currently selected frame up and down in the list, as well as delete it.
5. In the Playback pane you can test your animations and see if they play how you want. You can use the toolbar buttons to advance/reverse frame by frame, goto first/last frames, and play/stop playback.
NOTE: Currently all animations loop in the editor.
6. Click the "Save" toolbar button in the "Animations" pane to save your animations. The file will be saved as "yourfilename.aaf" which is just a plain text file containing the region and animation information.
7. Click the "Export" toolbar button in the "Animations" pane to export the animations for use in your game. The file will be exported as "yourfilename.json" which you might guess, is a JSON file containing the region and animation data.
HOWTO - GIDEROS:The included example project has a bunch of buttons that you can click to play different animations, and a bunch of extra code. The most basic example I can come up with is as follows...
require("json") -- FOR OPERATIONS ON JSON DATA
local File = File.new() -- FOR FILE OPERATIONS
local Animator = Animator.new() -- THE ANIMATOR CLASS
local playerAtlas = Texture.new("images/player.png")-- LOAD ATLAS
local player = Actor.new(TextureRegion.new(playerAtlas, 0, 0, 0, 0)) --CREATE PLAYER ACTOR
stage:addChild(player)
local playerAnimations = File:loadJSON("images/player.json") -- LOAD ANIMATIONS
Animator:attach(player, playerAnimations) -- ASSIGN ANIMATIONS TO PLAYER
Animator:set(player, "run") - START ANIMATION
local function onEnterFrame(event) -- MAIN PROGRAM LOOP
local timer = os.timer()
local dt = timer - currentTimer
currentTimer = timer
Animator:update(player, dt) -- UPDATE PLAYER ANIMATION
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) |
LIMITATIONS:Windows only (tested on Win8.1 64-bit), requires .net Framework 3.5
An animation file can contain only 128 animations.
Each animation can contain 64 animation frames.
I'm sure there are other things I forgot, just ask
UPDATES:
14/3/16 - Updated Animator class to skip unnecessary calls to setRegion(). Thanks
@keszegh15/3/16 - Updated Editor and screenshot to fix Sc rollbar in "TextureAtlas" pane that was too short.
Comments
so it's a combination of frames and tweens that you can use movieclip for.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://deluxepixel.com
MovieClip is a bit limited, and could do with a few extra features such as getFrame(), reverse() and a way to step it instead of relying on its internal timers. The latter would prevent it from going out of sync, and allowing you to pause many MovieClips easily.
Overall, though, MovieClip is faster, and therefore lovelier, than GTween.
I even apply shader on each of them
Likes: antix
Likes: totebo
Likes: antix
Likes: totebo
Likes: antix
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I think it does the same thing, and it already has its editor. I use it and I am very happy about it.
http://www.tntparticlesengine.com/?page_id=405
The free version is compiled, but if you donate something you get the lua source
Likes: antix
I have already created an editor for my system, and now need to get the animator class working in Gideros.
Edited top post which includes my Animation Editor and a Gideros example project. Enjoy @};-
Likes: keszegh, totebo
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: antix
in any case your class is already great for frame by frame animation and mc is good for tween animation.
Likes: antix
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: antix
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I will have to test which is faster, checking and not setting regions, or just setting regions every time
With regards to mirroring MovieClips, I should find out more about how they work and what they do. I gave up on them when I discovered they create too many Bitmaps.
So with MovieClip and GTween.. What is the difference?
one movieclip can combine many tweens and frame based animation into one anim that you can simply 'play'. this could be done with making the many tweens of course but would be much more complicated.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
like a MovieClipTextureBased (or the same name MovieClip with some flag when created, to mark that it's defined differently) in which the constructor timeline is not containing elements of type
{1, 100, sprite, {x = {0, 200, "linear"}}}
but rather
{1, 100, textureregion, {x = {0, 200, "linear"}}}
and when playing such an mctb, when the texture is the same and only the region changed, it would work internally as antix's solution, that is, only set the new region.
this way only as many sprites would be created by the movieclip as necessary. in most cases only one, if all the frames fit in one texture.
of course antix can modify his code to work like this but i guess changing mc to work like this might be less work and useful enough to put it into the core code.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
{1, 100, textureregion, {x = {0, 200, "linear"}},{texturebased=true,startScaleX=2}}
Fragmenter - animated loop machine and IKONOMIKON - the memory game