Game Development Reference
In-Depth Information
* width and height within the bitmap.
*
* @return A sprite with the image found in the ui bitmap.
*
*/
protected function _createSprite(r:Rectangle):Sprite {
var bmd:BitmapData;
bmd = new BitmapData(r.width, r.height, true, 0);
bmd.copyPixels(m_ui, r, new Point(0, 0));
var sprite:Sprite = new Sprite();
sprite.graphics.beginBitmapFill(bmd, null, false, true);
sprite.graphics.drawRect(0, 0, r.width, r.height);
sprite.graphics.endFill();
return sprite;
}
public function getStartBtn():Sprite {
// It is required that we know the
// exact top-left co-ordinates
// of the asset we want to cut
// as well as the width and height.
return _createSprite(new Rectangle(150, 200, 100, 100));
}
}
}
 
Search WWH ::




Custom Search