Objective c 从pvr纹理中奇怪地定位ccsprite

Objective c 从pvr纹理中奇怪地定位ccsprite,objective-c,cocos2d-iphone,kobold2d,Objective C,Cocos2d Iphone,Kobold2d,我使用Kobold2D+TexturePacker(两者都是目前的最新版本) 当我使用spriteWithFile:方法创建一个CCSprite对象并按其应该的位置放置时,它看起来很好 CGSize screenSize = [CCDirector sharedDirector].winSize; background = [CCSprite spriteWithFile:@"dir_bg.png"]; background.position = CGPointMake(screenSize.

我使用Kobold2D+TexturePacker(两者都是目前的最新版本)

当我使用spriteWithFile:方法创建一个CCSprite对象并按其应该的位置放置时,它看起来很好

CGSize screenSize = [CCDirector sharedDirector].winSize;

background = [CCSprite spriteWithFile:@"dir_bg.png"];
background.position = CGPointMake(screenSize.width - background.texture.contentSize.width / 2 - 10, background.texture.contentSize.height / 2 + 10);

[self addChild:background];

controller = [CCSprite spriteWithFile:@"dir_big.png"];
controller.position = background.position;

[self addChild:controller];

但使用另一种方法,使用spriteWithPriteFrameName:加载纹理时,对象不会按其应有的方式放置

[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Textures.plist"];

CGSize screenSize = [CCDirector sharedDirector].winSize;

background = [CCSprite spriteWithSpriteFrameName:@"dir_bg.png"];
background.position = CGPointMake(screenSize.width - background.texture.contentSize.width / 2 - 10, background.texture.contentSize.height / 2 + 10);

[self addChild:background];

controller = [CCSprite spriteWithSpriteFrameName:@"dir_big.png"];
controller.position = background.position;

[self addChild:controller];


为什么?

使用
background.contentSize.width
背景.contentSize.width等等


来源:

您正在加载3个精灵:背景加上2个不同的“控制”精灵;这是我在你发布的两张图片中看到的;另一方面,我只能看到对
spriteWithFile
的两个调用。我遗漏了什么吗?一些TexturePacker设置可能会导致这种情况,例如修剪设置(不要使用齐平位置)。检查精灵属性是否相同,主要是位置、锚点和内容大小。如果它们不同,请更新您的question.sergio,这些命令只需要一个方向控制CCNode,以及两个CCSprite——背景和轮子。一般来说,有带有贴图背景的CCLayer和带有CCSprites.learncos2D的两个ccnode,我尝试了不同的设置,特别是使用了none/trim/crop,但它们没有产生任何效果,仍然显示为移位。也许我错过了什么?“检查精灵属性是否相同,主要是位置、主播点和内容大小”是什么意思?