Matrixで回転
♥0 |
Line 26 |
Modified 2010-08-17 18:45:55 |
MIT License
archived:2017-03-20 07:51:36
ActionScript3 source code
/**
* Copyright _wonder ( http://wonderfl.net/user/_wonder )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fqsC
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
public class FlashTest extends Sprite {
private var angle:Number = 0;
private var box:Sprite;
public function FlashTest() {
init();
}
private function init():void {
box = new Sprite();
box.graphics.beginFill( 0xff0000 );
box.graphics.drawRect( -50, -50, 100, 100 );
box.graphics.endFill();
addChild( box );
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
angle += 0.1;
var cos:Number = Math.cos( angle );
var sin:Number = Math.sin( angle );
box.transform.matrix = new Matrix( cos, sin, -sin, cos, stage.stageWidth / 2, stage.stageHeight / 2);
}
}
}