Created
April 26, 2014 06:42
-
-
Save z-ohnami/11313424 to your computer and use it in GitHub Desktop.
OpenFL rotation image via center position.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.display.BitmapData; | |
import flash.display.Bitmap; | |
import openfl.Assets; | |
class Act005 extends Sprite | |
{ | |
private var _bmpData:BitmapData; | |
private var _bmp:Bitmap; | |
private var _sprite:Sprite; | |
public function new() | |
{ | |
super(); | |
addEventListener(Event.ADDED_TO_STAGE, init); | |
} | |
private function init(event:Event) | |
{ | |
removeEventListener(Event.ADDED_TO_STAGE, init); | |
_sprite = new Sprite(); | |
_sprite.x = (stage.stageWidth) / 2; | |
_sprite.y = (stage.stageHeight) / 2; | |
_bmpData = Assets.getBitmapData ("img/my-kamon1.png"); | |
_bmp = new Bitmap(_bmpData); | |
_bmp.scaleX = 0.5; | |
_bmp.scaleY = 0.5; | |
_bmp.x = -(_bmp.width / 2); | |
_bmp.y = -(_bmp.height / 2); | |
_sprite.addChild(_bmp); | |
addChild(_sprite); | |
_sprite.rotation = 45; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment