繁体   English   中英

Actionscript 3.0 围绕其中心点旋转精灵

[英]Actionscript 3.0 Rotating a sprite around its center point

我在网上搜索并找到了这个应该旋转和图像的脚本,但我不确定如何使用,在哪里放置我希望我的精灵旋转的度数。 另外,我得到一个错误。 1084:语法错误:在左括号之前需要标识符。 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;
}

将 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;
}

代码中的45是您要旋转的度数,只需更改该值即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM