[英]Actionscript 3.0 Rotating a sprite around its center point
I searched online and found this script that is supposed to rotate and image but I'm not sure how to use, where to put in the degree angle that I want my sprites to rotate by.我在网上搜索并找到了这个应该旋转和图像的脚本,但我不确定如何使用,在哪里放置我希望我的精灵旋转的度数。 Also, I get an error.另外,我得到一个错误。 1084: Syntax error: expecting identifier before leftparen. 1084:语法错误:在左括号之前需要标识符。 1084: Syntax error: expecting rightparen before leftbrace. 1084:语法错误:在左大括号之前需要右括号。
var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;
m.ty -= point.y;
m.rotate (angleDegrees*(Math.PI/180));
m.tx += point.x;
m.ty += point.y;
ob.transform.matrix=m;
}
fix the function to this将 function 修复到此
function rotateAroundCenter (ob:*, angleDegrees) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;
m.ty -= point.y;
m.rotate = (angleDegrees*(Math.PI/180)); // was a missing "=" here
m.tx += point.x;
m.ty += point.y;
ob.transform.matrix=m;
}
The 45
in your code is the degrees that you want to rotate by, just change that value.代码中的45
是您要旋转的度数,只需更改该值即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.