Clients Login
Search tips and advanced search
Lets Socialize
Hybrid Mindset on Twitter  Hybrid Mindset on LinkedIn  Hybrid Mindset on Facebook  Hybrid Mindset RSS Feed 
Want to be a guest blogger? Sign up and share your thoughts...
Blog Page Heading
Featured Blog

My PushButton Engine Experience Week 3...7

Serialization, Serialization...

Posted Date: 2010-08-24   Posted Time: 01:24:59
Print Blog PostPrint  Tweet Blog PostTweet This Comment On Blog PostComment 

Blog Posts

View All

My PushButton Engine Experience Week 2

Created: Friday, June 18, 2010 @ 01:54 PM  

Its been a pretty busy week so far. As I suspected working on a custom PBE component has given me the opportunity to learn quite a bit about the engine. I was able to figure out an isometric sorting algorithm that works well, I've started building the IsometricComponent Editor to give developers an easy to use tool for creating and saving Isometric Scenes, and I've also begun initial implementations of the IsoBox2DSpatialComponent which allows for collision detection handling in your isometric scene. i've split this Box2D integration into its own IsoPhysics library so that you guys can choose whether you want to use Box2D for your collision detection or right your own collision detection methods by extending the IsoSceneLayoutRenderer class of the Isometric component.


Isometric Collisions using Box2D


I just used circles attached to the origin of the Isometric box to perfom initial tests of collisions. Using the method described below u can create custom form fitting collision shapes easily using the flash IDE.


Isometric collision shapes built from swf library assets


One really cool feature that I am implementing is the ability to draw the isometric collision shapes of your isometric component from sprite assets embedded into a swf file using the flash IDE. This is an idea borrowed from a blog I came across by James Ford. This is awesome because you can import all your Isometric assets and build form fitting collision shapes for each one of them all right in the flash IDE and compile all of them into one or many Resource.swf bundle(s) that can be loaded into your PBE game using the Resource manager. With the new xml file format for flash files in CS5 you can now version control all those assets as well. Later I will show you how you can create a class reference in AS3 that references the exact asset in the swf using the class name that you set in the flash IDE instead of having the flash compiler load the whole swf if its not needed.


I'm really excited about this work flow because I love the idea of gathering all the assets for a given level of a game into one flash file and then being able to load this asset.swf into an Isometric level editor, and choose assets to be placed in the scene as needed. I can then jump back to the flash IDE, update an assets' registration point or the look of the asset, then get automatic asset updating in my AIR level editor that can now listen for filesystem changes using the new AIR 2.0 sdk. Thats a pretty decent workflow if you ask me.


View collision shape creation tutorial


Things to know about the upcoming Isometric Component


- When you instantiate an IsometricComponent if you set the autoAssign flag on the constructor to true, It will look for a component called 'Spatial' on the owner entity and auto wire up the position and isometricVolume properties to the Iso renderer. This is just for convenience and saves you a few lines of code. **Note the Spatial component would have to be added to the entity before the IsometricComponent for this flag to perform the wire up onAdd() of the IsometricComponent. It will not throw an error or warning message if you do not set the auto assign flag to true. [updated 06-18-2010 11:31pm]


- IsoBaseComponent can be used directly and populated with a native AS3Iso component by setting the isoComponent property. This will allow you to create an AS3Iso component of any kind, set any properties you would like then assign it to the IsoComponent.


- To import just a symbol from an embedded swf use the symbol key in your embed tag as such: 


[Embed(source="assets/swfs/Building.swf", symbol="buildingShape")]
public var buildingCollisionShape : Class;


The symbol name corresponds to the class name you set back in the flash IDE. I will have documentation on how to actually implement the Isometric Component once it is released.


Few Key Points


- Inter-Component Communication
The way that the different composited components tie together and share information within the context of an entity is by using property references and owner event listeners. So you can create a position property reference on your GameInput Component that retrieves the position data from a renderer component and updates it's value directly. You can also add an event listener on the owner property of an EntityComponent to listen for entity wide event broadcast. So your collision component can dispatch a collision event and any other component within that entity has the ability to register for that event and act on it.


- onAdd() & OnRemove()
A good practice is to place your creation code in the onAdd() method of your entityComponent and do your clean up in the onRemove method. These methods are called whenever an entity component is added then removed from an IEntity. This for example, is where you would wire up your owner event listeners and then release them in the onRemove method call.


- Console Action
One of the really cool features of the PushButton Engine is the console window. You just press the "~" key while your application is running and it will come up. It also has tab completion similar to a linux terminal window. You can also type "help" to get a list of commands.


- Logging
The PBE also comes with a built in Logger. A really convenient helper class to output error, warning, and regular messages to the console.


Feel free to leave comments, I welcome the feedback!




Categories
 Twitter Feed
@hybridmindset