{"id":159,"date":"2011-01-08T13:39:45","date_gmt":"2011-01-08T12:39:45","guid":{"rendered":"http:\/\/www.aymericlamboley.fr\/blog\/?p=159"},"modified":"2011-01-08T13:42:18","modified_gmt":"2011-01-08T12:42:18","slug":"testing-as3isolib","status":"publish","type":"post","link":"http:\/\/www.aymericlamboley.fr\/blog\/testing-as3isolib\/","title":{"rendered":"Testing as3isolib"},"content":{"rendered":"<p>Hi, folks !<\/p>\n<p>I know my last post was taken a while, the sandwich course is really intensive. However I will try to post more article. I&#8217;ve made many experiments since two months that I would like to share : stuff on games engine and datastructure.<\/p>\n<p>For this firts post of 2011 (already !), I will introduce the actionscript isometric library : <a href=\"http:\/\/as3isolib.wordpress.com\/\">as3isolib<\/a>. There are two others actionscript isometric library : <a href=\"http:\/\/www.theoworlds.com\/\">TheoWorlds<\/a> and <a href=\"http:\/\/www.openspace-engine.com\/\">OpenSpace<\/a> but they are not free !<\/p>\n<p>We will create an isometric world and add random boxes, if you click on one it will be removed. <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/01\/as3isolib.swf\" rel=\"lightbox[flash 800 600]\"><strong>The result.<\/strong><\/a><\/p>\n<p>The code :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">package {\r\n\r\n\timport as3isolib.display.IsoView;\r\n\timport as3isolib.display.primitive.IsoBox;\r\n\timport as3isolib.display.scene.IsoGrid;\r\n\timport as3isolib.display.scene.IsoScene;\r\n\timport as3isolib.enum.RenderStyleType;\r\n\timport as3isolib.geom.IsoMath;\r\n\timport as3isolib.geom.Pt;\r\n\timport as3isolib.graphics.SolidColorFill;\r\n\r\n\timport eDpLib.events.ProxyEvent;\r\n\r\n\timport flash.display.Sprite;\r\n\timport flash.events.Event;\r\n\timport flash.events.MouseEvent;\r\n\timport flash.events.TimerEvent;\r\n\timport flash.utils.Timer;\r\n\r\n\tpublic class Main extends Sprite {\r\n\r\n\t\tprivate const _CELL_SIZE:uint = 50;\r\n\r\n\t\tprivate var _grid:IsoGrid;\r\n\t\tprivate var _scene:IsoScene;\r\n\t\tprivate var _view:IsoView;\r\n\r\n\t\tprivate var _box:IsoBox;\r\n\t\tprivate var i:uint;\r\n\t\t\r\n\t\tprivate var _timerCreationBox:Timer;\r\n\r\n\t\tpublic function Main() {\r\n\r\n\t\t\tthis.addEventListener(Event.ADDED_TO_STAGE, _init);\r\n\t\t}\r\n\r\n\t\tprivate function _init(evt:Event):void {\r\n\r\n\t\t\tthis.removeEventListener(Event.ADDED_TO_STAGE, _init);\r\n\r\n\t\t\t_grid = new IsoGrid();\r\n\t\t\t_grid.setGridSize(10, 10, 1);\r\n\t\t\t_grid.showOrigin = false;\r\n\t\t\t_grid.cellSize = _CELL_SIZE;\r\n\r\n\t\t\t_scene = new IsoScene();\r\n\t\t\t_scene.hostContainer = this;\r\n\t\t\t_scene.addChild(_grid);\r\n\r\n\t\t\t_view = new IsoView();\r\n\t\t\t_view.setSize(800, 600);\r\n\t\t\t_view.centerOnPt(new Pt(200, 200, 0));\r\n\t\t\t_view.addScene(_scene);\r\n\t\t\tthis.addChild(_view);\r\n\t\t\t\r\n\t\t\t_timerCreationBox = new Timer(300, 0);\r\n\t\t\t_timerCreationBox.addEventListener(TimerEvent.TIMER, _createNewBox);\r\n\t\t\t_timerCreationBox.start();\r\n\t\t\t\r\n\t\t\tthis.addEventListener(Event.ENTER_FRAME, _ef);\r\n\t\t}\r\n\t\t\r\n\t\tprivate function _createNewBox(tEvt:TimerEvent):void {\r\n\t\t\t\r\n\t\t\t_box = new IsoBox();\r\n\t\t\t_box.styleType = RenderStyleType.SHADED;\r\n\t\t\tvar couleur:uint = Math.random() * 0xFFFFFF;\r\n\t\t\tvar alpha:Number = Math.random();\r\n\t\t\t_box.fills = [new SolidColorFill(couleur, alpha), new SolidColorFill(couleur, alpha), new SolidColorFill(couleur, alpha), new SolidColorFill(couleur, alpha), new SolidColorFill(couleur, alpha), new SolidColorFill(couleur, alpha)];\r\n\t\t\t\r\n\t\t\t_box.setSize(_CELL_SIZE, _CELL_SIZE, _CELL_SIZE);\r\n\t\t\t_box.moveTo(_CELL_SIZE * Math.floor(Math.random() * 10), _CELL_SIZE * Math.floor(Math.random() * 10), 0);\r\n\t\t\t\r\n\t\t\t_box.id = \"box\" + i;\r\n\t\t\t++i;\r\n\t\t\t\r\n\t\t\t_box.addEventListener(MouseEvent.CLICK, _deleteBox);\r\n\t\t\t_scene.addChild(_box);\r\n\t\t}\r\n\t\t\r\n\t\tprivate function _deleteBox(mEvt:ProxyEvent):void {\r\n\t\t\t\r\n\t\t\tmEvt.proxyTarget.removeEventListener(MouseEvent.CLICK, _deleteBox);\r\n\t\t\t_scene.removeChildByID(mEvt.target.id);\r\n\t\t}\r\n\t\t\r\n\t\tprivate function _ef(evt:Event):void {\r\n\t\t\t_scene.render();\r\n\t\t}\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>The _scene.render() function is really important : it updates the scene of all your graphical change !<\/p>\n<p>Later it will be a post on Box2d, stay tuned !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, folks ! I know my last post was taken a while, the sandwich course is really intensive. However I will try to post more article. I&#8217;ve made many experiments since two months that I would like to share : stuff on games engine and datastructure. For this firts post of 2011 (already !), I &hellip; <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/testing-as3isolib\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Testing as3isolib<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[4,11],"tags":[],"_links":{"self":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/159"}],"collection":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":2,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":161,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions\/161"}],"wp:attachment":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}