Cocos2d iphone 在iPhone模拟器中运行而不是在iPhone 4上运行的代码块?(COCOS2D)

Cocos2d iphone 在iPhone模拟器中运行而不是在iPhone 4上运行的代码块?(COCOS2D),cocos2d-iphone,Cocos2d Iphone,我使用的是CCTouchBegind和CCTouchEnd,由于某种原因,有一段代码在iPhone模拟器上运行得很好,但在iPhone 4上根本不运行。我的方法是这样的: -(BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent *)event { firstTouch = [self convertTouchToNodeSpace:touch]; if (!self.currentFootball.footballHasEmbarked)

我使用的是CCTouchBegind和CCTouchEnd,由于某种原因,有一段代码在iPhone模拟器上运行得很好,但在iPhone 4上根本不运行。我的方法是这样的:

-(BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent *)event {

firstTouch = [self convertTouchToNodeSpace:touch];

if (!self.currentFootball.footballHasEmbarked) {

    //arrow.position = ccp(fPos.x, fPos.y);
    float newAnc = (120 + (self.currentFootball.contentSize.width * .5f) + (arrow.contentSize.width * .5f)) / arrow.contentSize.width;
    arrow.anchorPoint = ccp(-newAnc, .5);//self.currentFootball.position;
    arrow.position = self.currentFootball.position;//ccp(fPos.x-120, fPos.y);
arrow.rotation = 180;
arrow.visible = YES;
arrow.scale = 0.5f;

    //powerLevel.position = fPos;
    powerLevel.position = self.currentFootball.position;
    powerLevel.rotation = 180;
powerLevel.percentage = 0;
powerLevel.visible = YES;

    outLine.position = self.currentFootball.position;
    outLine.rotation = 180;
    outLine.visible = YES;

    CCProgressFromTo *powerBarGoUp = [CCProgressFromTo actionWithDuration:1.0f from:0.0f to:100.0f];

    CCProgressFromTo *powerBarGoDown = [CCProgressFromTo actionWithDuration:1.0f from:100.0f to:0.0f];

    id action = [CCRepeatForever actionWithAction:[CCSequence actions:powerBarGoUp, powerBarGoDown,  nil]];
    [powerLevel runAction:action];

    return YES;
}
else {
    return NO;
}
}

}

这是一段不会在我的iPhone上运行的代码

if (CGPointEqualToPoint(endTouch, firstTouch)) {
    CCLOG(@" I have run");
    float   anchorPointDist = ccpLength(endTouch);

    float   distFactor = distFromFb + anchorPointDist;

    projectionAnchorPoint = ccp(firstTouch.x + distFactor,firstTouch.y);

}

我做得不对吗?

打印endTouch和firstTouch的值。它们在设备上的变化量可能非常小,因为要将手指保持在与鼠标指针相反的位置比较困难。如果是这种情况,您可能希望在第一次触摸的范围内接受结束触摸。

打印出endTouch和firstTouch的值。它们在设备上的变化量可能非常小,因为要将手指保持在与鼠标指针相反的位置比较困难。如果是这种情况,您可能希望在第一次触摸的范围内接受结束触摸。

可能您正在比较的点之间存在一些细微的差异,使得该比较的结果总是错误的。尝试使用此方法而不是CGPointEqualToPoint

BOOL ccpFuzzyEqual(CGPoint a, CGPoint b, float variance);

也许在你比较的点上有一些细微的差别,使得比较的结果总是错误的。尝试使用此方法而不是CGPointEqualToPoint

BOOL ccpFuzzyEqual(CGPoint a, CGPoint b, float variance);

你能解释一下你想做什么吗?你在做什么姿势?你能解释一下你想做什么吗?你在处理什么样的手势?ccpFuzzyEqual允许多少变化?对不起,应该仔细看看ccpFuzzyEqual。谢谢你的帮助。ccpFuzzyEqual允许多少变化?对不起,我应该更仔细地看看ccpFuzzyEqual。谢谢你的帮助。