我定义使用spriteWithFile方法的精灵,提供了一个120像素的30像素png格式的cocos2d精灵contentSize问题
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
我缺少的东西?这不应该是由30.000000 120.000000
任何帮助将不胜感激。
问候,
丰富
蹦床是Sprite的一个子类。线trampoline = [Trampoline节点]正在初始化我的对象。 蹦床不是空的,因为它有它的位置设置,并显示在我的屏幕上的图像。 – Rich 2009-07-10 18:44:58