Skip to content

Instantly share code, notes, and snippets.

@jplattel
Created October 30, 2012 12:25
Show Gist options
  • Save jplattel/3979892 to your computer and use it in GitHub Desktop.
Save jplattel/3979892 to your computer and use it in GitHub Desktop.
package { import as3isolib.graphics.SolidColorFill; import flash.net.URLRequest; import flash.display.Loader; import flash.events.*; import as3isolib.enum.IsoOrientation; import flash.display.Bitmap; import as3isolib.graphics.BitmapFill; import as3isolib.display.IsoSprite; public class BoxFactory { private var stage:Object; private var view:ViewMediatheek; private var mySprite = new IsoSprite(); private function imgLoadComplete(e:Event):void { var myImg:Bitmap = new Bitmap(e.target.content.bitmapData); mySprite.sprites = [myImg]; } private var position:Object = { x: 0, y: 0, z: 0 } private var size:Object = { x: MediatheekConstante.gridSize, y: MediatheekConstante.gridSize, z: MediatheekConstante.gridSize - 10 } private var color:int = 0x000000; public function BoxFactory( stage:Object, view:ViewMediatheek ) { this.stage = stage; this.view = view; } public function createBox( position:Object, color, size:Object ):void { var box:Box = new Box(stage, view); if( position == null ) position = this.position; if( color == null ) color = this.color; if( size == null ) size = this.size; box.moveTo( position.x, position.y, position.z ); box.fills = [ new SolidColorFill(color, 1), new SolidColorFill(color, 1), new SolidColorFill(color, 1), new SolidColorFill(color, 1), new SolidColorFill(color, 1), new SolidColorFill(color, 1) ]; box.setSize( size.x, size.y, size.z ); view.scene.addChild( box ); box.fillCollision( position.x, position.y, true ); } public function createZuil( position:Object ):void { var myImgLoader:Loader = new Loader(); var myImgURL:URLRequest = new URLRequest("gfx/zuil.png"); myImgLoader.load(myImgURL); myImgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoadComplete); mySprite.setSize(50, 50, 50); mySprite.moveTo( position.x - 30, position.y - 0, position.z + 100); view.scene.addChild( mySprite ); } public function createCloset( position:Object ):void { var box:Kast = new Kast(stage, view); //if( position == null ) position = this.position; position.x = Math.round( position.x / 50 ) * 50; position.y = Math.round( position.y / 50 ) * 50; box.moveTo( position.x, position.y, position.z ); view.scene.addChild( box ); box.fillCollision( position.x, position.y, true ); } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment