그래서 내 게임 나는 배열에 여러 스프라이트를 추가하고 있고 더 많은 스프라이트 나는 빨리 내 게임을 실행하기 시작 추가? 내 질문에 것 같아요,이 같은 스프라이트 추가 및 For 루프에서 해당 속성을 호출하는 문제를 만들지 않습니다? 또는 문제가 다른 곳에서 발생합니다. 나는 "지상"스프라이트를 더 추가하면 점프 높이, 이동 속도 및 스크롤 속도가 증가한다는 것을 확인했습니다. 이 문제를 해결하기 위해 기와로 전환해야합니까?스프라이트는
gravity -= 2 ;
for(CCSprite *ground in boxes){
if(CGRectIntersectsRect(_character.boundingBox, ground.boundingBox) && !jump && (_character.position.y > ground.position.y + ground.contentSize.height/2 -20) && _character.position.x > ground.position.x - ground.contentSize.width/2 && facingLeft)
{
_character.position = ccp(_character.position.x, ground.position.y + ground.contentSize.height/2 + _character.contentSize.height/2-.001);
falling = NO;
onGround = YES;
gravity = 0;
if(!_moving){
[_character setDisplayFrame:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"1-1.png"] ];
}
}
else if(CGRectIntersectsRect(_character.boundingBox, ground.boundingBox) && !jump && (_character.position.y > ground.position.y + ground.contentSize.height/2-20) && _character.position.x < ground.position.x + ground.contentSize.width/2 && !facingLeft)
{
_character.position = ccp(_character.position.x, ground.position.y + ground.contentSize.height/2 + _character.contentSize.height/2-.001);
falling = NO;
onGround = YES;
gravity = 0;
if(!_moving){
[_character setDisplayFrame:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"1-1.png"] ];
}
}
else if(CGRectIntersectsRect(_character.boundingBox, ground.boundingBox) && (targetX <= 0) && (_character.position.y +_character.contentSize.height < ground.position.y + ground.contentSize.height) && (_character.position.x > ground.position.x) && (gp.isControlling && (gp.controlQuadrant == 2 || gp.controlQuadrant == 3)))
{
backgroundX = 0;
targetX = 0;
}
else if(CGRectIntersectsRect(_character.boundingBox, ground.boundingBox) && (_character.position.y +_character.contentSize.height < ground.position.y + ground.contentSize.height) && (_character.position.x < ground.position.x) && (gp.isControlling && (gp.controlQuadrant == 0 || gp.controlQuadrant == 1)))
{
backgroundX = 0;
targetX = 0;
}
else
{
normalForce = 0;
jump = NO;
falling = YES;
doubleJump = 0;
}
// totalForce = normalForce + gravity;
// [_character setPosition:ccp(_character.position.x, _character.position.y+totalForce)];
}
totalForce = normalForce + gravity;
if(gravity == 0) {
falling = NO;
NSLog(@"Gravity = 0");
}
[_character setPosition:ccp(_character.position.x + targetX, _character.position.y + totalForce)];
: 나는 배열에 이미지를 추가하고 내 캐릭터 스프라이트와 접지 사이의 교차로 같은 것들에 대해 검사 할 때이 같은 루프를 사용하는 경우
는
CCSprite *ground = [CCSprite spriteWithFile:@"testlevel 5.png"];
[ground setPosition:ccp(520, 10)];
[ground setScale:1.0];
//[ground setScaleX:(2 * ground.contentSize.width)];
[self addChild:ground z:0];
[boxes addObject:ground];
ground = [CCSprite spriteWithFile:@"testlevel 4.png"];
[ground setPosition:ccp(ground.contentSize.width/2 +400, -50)];
[ground setScale:1.0];
//[ground setScaleX:(2 * ground.contentSize.width)];
[self addChild:ground z:0];
[boxes addObject:ground];
ground = [CCSprite spriteWithFile:@"testlevel 3.png"];
[ground setPosition:ccp(ground.contentSize.width/2 +280, -10)];
[ground setScale:1.0];
//[ground setScaleX:(2 * ground.contentSize.width)];
[self addChild:ground z:0];
[boxes addObject:ground];
이 위의 세그먼트입니다 점프는 중력의 약 10 intager 추가 간단한 버튼에 의해 제어된다}
. I는 중력과 같습니다 내 틱 기능을 실행하는 타이머가 있습니다
gravity -=1;
을하고 내 문자 위치로 그 값을 추가, 중력이 0으로 설정됩니다 때 상자의 상단에. 왼쪽/오른쪽 플레이어는 틱 기능으로 속도를 업데이트하는 조이스틱으로 제어됩니다. 더 많은 정보가 필요하다면 알려주세요. 그러나 다시 말하면, 배열에 스프라이트를 추가하면 알 수없는 이유로 속도가 변경됩니다. 어떤 도움이라도 대단히 감사 할 것입니다. 여기
코드에서 점프-(void)jumpTapped
{
NSLog(@"PRESSED");
if(!falling && onGround){
doubleJump += 1;
gravity += 10;
jump = YES;
onGround = NO;
NSLog(@"JUMPING");
}
}
에 대한 전체 내용을 쓸 수 있습니까? (상자에 CCSprite * 접지) 코드? 나는 그것이 그래서 간단하게 코드를 찾고 후 무엇을 말할 수에서 모든 –
거기에있는 코드를 함께 할 수있는 뭔가가 느낌이있는 것은 I가 추측 오전하기 만 문을 반환하는 경우 중 하나가 될해야한다는 것입니다 사실, 맞습니까? – user1569940
해야 당신이 –