同じタグを持つすべてのスプライトを数インチ右に移動しようとしています。そのために 4 つの異なるタイプの式を試しましたが、何も機能しませんでした。これが私がこれまでに行ったことです...
-(void) moveSprites {
NSArray* spritesWithTag = [lh spritesWithTag: BOXES1]
for (LHSprite* spr in spritesWithTag)
(NSLog (@"name is %@", [spr uniqueName]);
CGPoint newposition = ccpSub (ccp(-50,0), [spr position]);
//generating the new position for the elements
[spr transformPosition: newposition];
//first attemp, should work but for some reason it doesn't work
spr.position = newposition;
//2nd attemp
b2Vec2 newpositionVector (newposition.x, newposition.y);
[spr body]->SetTransform(newpositionVector, 0);
//third try
[spr setPosition:newposition];
//last form
}
アプリを実行すると、メソッド呼び出しは正常に機能し、タグ BOXES1 を持つすべてのスプライトが出力タブに表示されますが、その位置はまったく変更されていません。なぜそれが起こっているのかについての考え。私は何を間違えたのですか?スプライトを移動する他の方法はありますか、それとも私が知らない他の形で移動するのを妨げていますか? それらは静的なスプライトです。これが影響するかどうかはわかりません...ありがとう!