我正试图将相同标签的所有精灵移动到右边几英寸处。 为了做到这一点,我尝试了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的精灵都出现在输出选项卡中,但其位置根本没有改变。任何关于它为什么会发生的想法。我错了什么?有没有其他方法可以移动精灵,或者是否阻止他们以其他形式移动我不知道?那些是静态的精灵,不知道这是否影响......谢谢!