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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Create new class GameState that extends StarlingState<br />

File -­‐> New -­‐> ActionScript Class<br />

package<br />

{<br />

import Box2D.Dynamics.Contacts.b2Contact;<br />

import citrus.core.starling.StarlingState;<br />

import citrus.objects.platformer.box2d.Coin;<br />

import citrus.objects.platformer.box2d.Enemy;<br />

import citrus.objects.platformer.box2d.Hero;<br />

import citrus.objects.platformer.box2d.MovingPlatform;<br />

import citrus.objects.platformer.box2d.Platform;<br />

import citrus.physics.box2d.Box2D;<br />

public class GameState extends StarlingState<br />

{<br />

public function GameState()<br />

{<br />

super();<br />

}<br />

override public function initialize():void{<br />

super.initialize();<br />

var physics:Box2D = new Box2D("box2D");<br />

physics.visible = true;<br />

add(physics);<br />

var floor:Platform = new Platform("floor",{x: 512, y: 768, width:1024, height: 40});<br />

add(floor);<br />

var p1:Platform = new Platform("p1", {x:874, y: 151, width: 300, height:40});<br />

add(p1);<br />

var mp:MovingPlatform = new MovingPlatform("mp",{x:220, y:700, width:200, height: 40,<br />

startX: 220, startY: 700, endX:500, endY: 151});<br />

add(mp);<br />

var hero:Hero = new Hero("hero", {x:50, y:50, width: 70, height: 70});<br />

add(hero);<br />

var enemy:Enemy = new Enemy("enemy", {x:900, y:700, height:70, width: 70, leftBound: 10,<br />

rightBound:1000});<br />

add(enemy);<br />

var coin:Coin = new Coin("coin", {x: 967, y: 90, width: 79, height: 79});<br />

coin.onBeginContact.add(function(c:b2Contact):void{<br />

trace("CONTACT");<br />

});<br />

add(coin);<br />

}<br />

}<br />

}<br />

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

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

Saved successfully!

Ooh no, something went wrong!