objective c - How to set value of a property that's a custom object -
i'm trying keep track of sprite user has dragged/dropped on top of "rectangle" objects. thought easiest thing add property of same type "mysprite" "rectangle" objects , set it's value equal "mysprite" that's been dropped on top of it. thought using property "mysprite *sprite" in "rectangle.h" file along synthesizing in "retangle.m" file have automatically created "setsprite" method. i'm not understanding something....
the "target.sprite = selsprite;" line of code below in cocosscene.m causes following error:
2013-05-14 20:32:51.953 dragdrop[461:c07] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[ccsprite setsprite:]: **unrecognized selector sent instance 0x8d5c280'
rectangle.h
#import "ccnode.h" #import "cocos2d.h" #import "mysprite.h" @interface rectangle : ccnode { mysprite *sprite; } @property(nonatomic,readwrite,copy) mysprite *sprite; @end
rectangle.m
@implementation rectangle @synthesize sprite = _sprite; @end
cocosscene.m
for(rectangle *target in wordcirclerectangles) { if(cgrectintersectsrect(selsprite.boundingbox, target.boundingbox)) { target.sprite = selsprite; } }
Comments
Post a Comment