Game Development Reference
In-Depth Information
The following is the listing of a class that loads a .png file like the one shown
previously; it then cuts out the GO button from the file and puts it on the state. The
result of running the program is as follows:
package {
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import mx.core.BitmapAsset;
public class AssetSplicer extends Sprite
{
// Define the graphics file that contains
// all the ui you need
[Embed(source="ui.png")]
private var UIClass:Class;
// A placeholder that the file can be accessed
// as a bitmap data
private var m_ui:BitmapData;
public function AssetSplicer()
{
// Read the graphics file
var bma:BitmapAsset = new UIClass() as BitmapAsset;
m_ui = bma.bitmapData;
// Add a sprite to the stage made with
// cut out part of the start game ("go") asset
addChild(getStartBtn());
}
/**
* A handy method to create a sprite from m_ui BitmapData
*
* @param r The rectangle to specify the x, y,
 
Search WWH ::




Custom Search