ios - Not able to access the userdata property of the sprite -
in project having 10 sprite,each 1 having unique userdata value.during cctouch method copying sprite new sprite,
but cant able sprite userdata value.
my coding is
(int i=1; i<=10; i++) { ccsprite *zig=[ccsprite spritewithfile:[nsstring stringwithformat:@"zig%d.png",i]]; zig.position=ccp(325,60); zig.tag=i+1; zig.userdata=[nsstring stringwithformat:@"%@",[zigpositionarray objectatindex:i-1]]; [self addchild:zig z:2]; [zigblurarray addobject:zig]; nslog(@"userdata%@",zig.userdata); }
in cctouchbegan method:
for(ccsprite *s in zigblurarray) { if (cgrectcontainspoint(s.boundingbox, newpt1)) { temp=s; temp.userdata=s.userdata; nslog(@"%d",temp.tag); nslog(@"userdata%@",temp.userdata); }
finaly getting lldb error
0x170409b: movl 8(%edx), %edi exc_bad_access
please 1 me problem.
the string autoreleased. userdata
property of type void* , not retain object. use userobject
property instead (if available in cocos2d version) or retain string.
Comments
Post a Comment