Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import citrus.core.starling.StarlingState;
- import citrus.objects.platformer.box2d.Platform;
- import citrus.objects.platformer.box2d.Sensor;
- import citrus.physics.box2d.Box2D;
- import starling.display.Quad;
- /**
- * ...
- * @author david.hale
- */
- public class GameState extends StarlingState
- {
- public function GameState()
- {
- super();
- }
- override public function initialize():void
- {
- super.initialize();
- //add physics
- var physics:Box2D = new Box2D("box2d");
- physics.visible = true; //this adds the box outlines
- add(physics);
- //add a Box2D platform
- var floor:Platform = new Platform("floor", {x: 512, y: 750, width: 1024, height: 40});
- floor.view = new Quad(1024, 40, 0x000000);
- add(floor);
- //this is the Platform that we are climbing up to
- var p1:Platform = new Platform("p1", {x: 874, y: 151, width: 300, height: 40});
- p1.view = new Quad(300, 40, 0x222222);
- add(p1);
- //a Box2D Sensor
- var ladder1:Sensor = new Sensor("ladder1", {x: 874, y: 410, width: 20, height: 580});
- ladder1.view = new Quad(20, 580, 0x555500);
- //this is how we set this platform to be a ladder
- ladder1.isLadder = true;
- add(ladder1);
- //our modified Hero
- var hero:ladderHero = new ladderHero("hero", {x: 50, y: 50, width: 80, height: 80});
- //I have this in a separate function in case the level that I'm building doesn't actually have ladders, I can save a couple cycles
- hero.setHeroCanClimbLadders(true);
- add(hero);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement