Taurayi 氏が提供した解決策は本当に素晴らしいものです。しかし、私はエンターフレームでそれをしたくありません。ランダムな位置に回転するようにオブジェクトを微調整するだけです。ローテーションの条件を教えてください。オブジェクトがランダムポイントに向かって回転する必要があることを意味します。たとえば。もし(dx < 0){
dx += 360;
dy += 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
if(dx >= 360){
dx -= 360;
dy -= 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
if ( dy > 180 )
{
dx -= 360;
dy -= 360
angl = Math.atan(dy/dx) + deg2rad(-90);
InsectsVector[i].rotation = angl;
}
if ( dx < -180 )
{
dx += 360;
dy += 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
上記のこの条件は、以下のコーディングでは正しく機能しません。だから私にこれを知らせてください。
Please its very urgent dudes. And thanks in advance for replying.
private function InsectsRandPos():void{
randNum_1 = uint(Math.random()*50);
for (var i:uint=0; i < InsectsVector.length; i++){
while(InsecNode.indexOf(randNum_1) != -1){
randNum_1 = uint(Math.random()*50);
}
InsecNode[i] = randNum_1;
randPointForInsec = nodeContainer.getNodePostion(InsecNode[i]);
if(spNode != InsecNode[i]){
InsectsVector[i].visible = true;
nodeContainer.addChild(InsectsVector[i]);
var dx:Number = randPointForInsec.x - InsectsVector[i].x ;
var dy:Number = randPointForInsec.y - InsectsVector[i].y ;
var angl:Number = Math.atan(dy/dx) + deg2rad(90);
InsectsVector[i].rotation = angl; // (angl*-1)+180;
if( dx < 0){
dx += 360;
dy += 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
if(dx >= 360){
dx -= 360;
dy -= 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
if ( dy > 180 )
{
dx -= 360;
dy -= 360
angl = Math.atan(dy/dx) + deg2rad(-90);
InsectsVector[i].rotation = angl;
}
if ( dx < -180 )
{
dx += 360;
dy += 360;
angl = Math.atan(dy/dx) + deg2rad(90)
InsectsVector[i].rotation = angl;
}
var InsectTwee:Tween = new Tween(InsectsVector[i], 5, Transitions.LINEAR );
InsectTwee.animate("x", randPointForInsec.x);
InsectTwee.animate("y", randPointForInsec.y);
Starling.juggler.add(InsectTwee);
}
else if(spNode == InsecNode[i]){
var obj:Object = new Object();
obj = InsectsVector[i];
obj.visible = false;
trace("obj .name ..."+obj + " InsectsVector[i] :"+InsectsVector[i])
}
}
}