04.10.2013 Views

BUILDING A SIMPLE GAME WITH FLASH PRO

Adobe MAX 2013 Lab by Tom Krcha (Sr. Creative Cloud Evangelist at Adobe) Follow me on Twitter: @tomkrcha

Adobe
MAX
2013
Lab
by
Tom
Krcha
(Sr.
Creative
Cloud
Evangelist
at
Adobe)
Follow
me
on
Twitter:
@tomkrcha

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Embed the pregenerated sprite sheet to your level class by creating two variables this<br />

way:<br />

[Embed(source="../levels/hero.png")]<br />

private var heroAnimBitmap:Class;<br />

[Embed(source="../levels/hero.xml",mimeType="application/oc<br />

tet-stream")]<br />

private var heroAnimXML:Class;<br />

Now you can add this animation sequence to a hero using this code:<br />

var ta:TextureAtlas = new<br />

TextureAtlas(<br />

Texture.fromBitmap(new<br />

heroAnimBitmap()), XML(new<br />

heroAnimXML()));<br />

var animationSeq:AnimationSequence = new<br />

AnimationSequence(ta,["walk","idle", "jump"],"idle",24);<br />

hero.view = animationSeq;<br />

Where ["walk", "idle", "jump"] is an array of available animations and “idle” is the<br />

default state, 24 defines the frame rate (fps).<br />

Building a simple game with Flash Professional. MAX 2013 Lab by Tom Krcha (@tomkrcha) 13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!