我使用spriteWithFile方法定义了一个精灵,提供了一个120像素乘30像素的.png文件。
Sprite *trampoline = [Sprite spriteWithFile:@"trampoline.png"];
[self addChild:trampoline];
当我将这个添加到我的图层中并进行定位时,它出现在我期望的屏幕位置。
trampoline = [Trampoline node];
trampoline.position = ccp(160,15);
[self addChild:trampoline z:0 tag:1];
然而,它似乎没有contentSize。下面的NSLog语句:
NSLog(@"Content Size x:%f, y:%f", trampoline.contentSize.width,trampoline.contentSize.height);
提供以下读数:
2009-07-10 18:24:06.385 TouchSprite[3251:20b] Content Size x:0.000000, y:0.000000
我有点不明白,这不应该是120.000000乘以30.000000吗?
如有帮助,将不胜感激。
谢谢,
Rich