Calling object position from object in array?
i have a sprite in an array when calling it like this
[c1 objectAtIndex:0];
I want to call on the position of the sprite so like:
[c1 objectAtIndex:0].position.x;
Is there a way to do this or will i have to create another array that contains the sprite positions. Here is my problem:
if (mySpritePointers [nSprite]->position.x == myXPoints [nPoint] && mySpritePointers[nSprite]->position.y == myYPoints [nPoint]) {
i get an error 'struct CCSprite' h开发者_运维问答as no member named 'position'
You can call method for value of objectAtIndex with cast.
((CCSprite *)[c1 objectAtIndex:0]).position.x;
Or
CCSprite *sprite = (CCSprite *)[c1 objectAtIndex:0];
sprite.position.x
精彩评论