0

オンラインで検索したところ、回転して画像化するはずのこのスクリプトが見つかりましたが、使用方法、スプライトを回転させたい角度をどこに入れるかわかりません。また、エラーが発生します。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;
}
4

1 に答える 1

2

関数をこれに修正します

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は、回転させたい角度です。その値を変更するだけです。

于 2011-08-09T22:29:08.340 に答える