【问题标题】:Actionscript 3.0 Rotating a sprite around its center pointActionscript 3.0围绕其中心点旋转精灵
【发布时间】:2011-08-10 06:29:08
【问题描述】:

我在网上搜索并找到了这个应该旋转和成像的脚本,但我不确定如何使用,在哪里放置我希望我的精灵旋转的度数。 另外,我得到一个错误。 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;
}

【问题讨论】:

    标签: actionscript-3 rotation sprite center degrees


    【解决方案1】:

    修复这个函数

    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 是您要旋转的度数,只需更改该值即可。

    【讨论】:

    • 记录一下,rotate是个函数,应该没有=
    猜你喜欢
    • 1970-01-01
    • 2016-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多