【发布时间】:2013-06-10 20:20:24
【问题描述】:
cocos2d 1.0.1 版 xcode 4.6.2 iphone 6.1 模拟器 部署目标 4.3
我为我的游戏编写了简单的代码,其中我试图在触摸精灵时使精灵向左移动 10 点。 问题是当我触摸精灵时它向左移动并且精灵边界框向下移动,即精灵在-x 轴上移动但精灵边界框在-y 轴上移动。请帮我解决这个问题我不知道坐标系或设备方向设置是否有问题
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:[touch view]];
CCSprite *mysprite = (CCSprite*)[self getChildByTag:1];
if (CGRectContainsPoint([mysprite boundingBox], touchLocation)) {
[mysprite runAction:[CCMoveBy actionWithDuration:1 position:ccp(-10,0) ]];
}
}
【问题讨论】:
标签: objective-c cocos2d-iphone