Posts Tagged ‘iso’

Saturday, October 11th, 2008


as3isolib is a great isometric library for actionscript 3
by Justin Opitz.  This is a lower level isometric library that could be used in building your own isometric gaming engine or learning more about the popular isometric view in games or other flash content.

From building basic blocks…

To constructing sprites and objects with individual iso objects with their own bounding boxes.


This sample shows a two piece tree, a common issue with sprites in isometric is where to slice them up.  This sample shows a tree with the leaves able to be in front of a character so that you could walk under the tree and be in front of the trunk but covered by the trees.  Essentially height is respected.

Sample code for the tree tutorial:

package
{
import as3isolib.display.IsoSprite;
import as3isolib.display.primitive.IsoBox;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;

import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;

public class IsoApplication extends Sprite
{
 private var scene:IsoScene;
 private var assets:Object;

 private var loader:Loader

 private function loadAssets ():void
 {
  loader = new Loader();
  loader.contentLoaderInfo.addEventListener(Event.INIT, loader_initHandler);
  loader.load(new URLRequest("assets/swf/assets.swf"));
 }

 private function loader_initHandler (evt:Event):void
 {
  buildScene();
 }

 private function buildScene ():void
 {
  scene = new IsoScene();
  scene.hostContainer = this;
  scene.container.x = 200;
  scene.container.y = 200;

  var treeTrunkClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeTrunk") as Class;
  var treeLeavesClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeLeaves") as Class;

  var grid:IsoGrid = new IsoGrid();
  grid.showOrigin = false;
  scene.addChild(grid);

  var s0:IsoSprite = new IsoSprite();
  s0.setSize(25, 25, 65);
  s0.moveTo(50, 50, 0);
  s0.sprites = [treeTrunkClass];
  scene.addChild(s0);

  var s1:IsoSprite = new IsoSprite();
  s1.setSize(125, 125, 100);
  s1.moveTo(0, 0, 75);
  s1.sprites = [treeLeavesClass];
  scene.addChild(s1);

  scene.render();
 }

 public function IsoApplication ()
 {
  loadAssets();
 }
}
}

current features

  • simple scene creation
  • 3 primitive types
  • base class for displaying user-created content
  • plenty of styling option on vector based primitives
  • integrates well with a variety of tween engines
  • standard 3D isometric positional sorting

So get busy building the flash version of roller coaster tycoon…