我正在尝试跟踪用户在“Rectangle”对象上拖放的精灵。我认为最简单的做法是将相同类型“MySprite”的属性添加到“Rectangle”对象中,然后将其值设置为等于放在其上的“MySprite”。我想在“Rectangle.h”文件中使用“MySprite * sprite”属性,并在“Retangle.m”文件中合成它会自动创建“setSprite”方法。我不明白......
“target.sprite = selSprite;” CocosScene.m中下面的代码行导致以下错误:
2013-05-14 20:32:51.953 DragDrop [461:c07] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [CCSprite setSprite:]:**无法识别的选择器发送到实例 0x8d5c280'
#import "CCNode.h"
#import "cocos2d.h"
#import "MySprite.h"
@interface Rectangle : CCNode
{
MySprite *sprite;
}
@property(nonatomic,readwrite,copy) MySprite *sprite;
@end
@implementation Rectangle
@synthesize sprite = _sprite;
@end
for(Rectangle *target in wordCircleRectangles)
{
if(CGRectIntersectsRect(selSprite.boundingBox, target.boundingBox))
{
target.sprite = selSprite;
}
}