I create an SKSpriteNode
in didBeginContact
method with location of contact:
CommonBox *boxTwo = [[CommonBox alloc] initWithTexture:[self.mainAtlas textureNamed:@"box07"]];
boxTwo.name = @"regularBox";
boxTwo.position = contact.contactPoint;
[self addChild:boxTwo];
The position is correct here. Then update method is called and the position of box is magically changed to 0,0 at start of update method, before any code at all is executed. Why is that?
No other code is executed between these two events. This is driving me crazy. I tried removing all collision and contact bit masks from this object, but it changes to zeroes anyway. Object is legal and so on.
EDIT: if I remove physics body from that node I will get desired position. But how do I set my position of node if it has physics body?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…