如何通过触摸精灵将对象绑定到精灵?

时间:2014-08-23 21:16:37

标签: cocos2d-iphone ccsprite

我有一个这样的自定义类:

@interface TileSprite : NSObject

@property (nonatomic, retain) Tile * tile;
@property (nonatomic, retain) CCSprite * tileSp;
@property (nonatomic, retain) CCScene * parentScene;

- (id) initWithTile:(Tile *) t parentScene:(CCScene *) parent;

@end

我已将精灵添加到父场景中,如下所示:

TileSprite * tSprite = [[TileSprite alloc] initWithTile:tile parentScene:parentScene];
tSprite.tileSp.position = ccp(0.808 - 0.056 * i, 0.068);
tSprite.tileSp.name = @"bottom_concealed";
[parentScene addChild:tSprite.tileSp z:10];

我想通过触摸(CCSprite *)tileSp来获取(Tile *)tile对象。有人帮我出去吗?还有更好的方法来实现这个类吗?

0 个答案:

没有答案