sto sviluppando 'Paper Toss'
per iPhone utilizzando cocos2d
& Vorrei sapere che come implementare 3D
vista prospettica in questo, perché mentre stiamo gettando la palla di carta al raccoglitore, abbiamo per ottenere il 3D
feel.I'am allegando il codice che ho fatto, utilizzando questo ho avuto una linea retta motion.Please aiutarmi ..vista prospettica 3D nel gioco iPhone utilizzando cocos2d
*- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// Choose one of the touches to work with
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
// Set up initial location of projectile
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *projectile = [CCSprite spriteWithFile:@"ball.png"
rect:CGRectMake(0, 0, 40, 40)];
projectile.position = ccp(winSize.width/2,20);
// Determine offset of location to projectile
int offX = location.x - projectile.position.x;
int offY = location.y - projectile.position.y;
// Bail out if we are shooting down or backwards
if (offY <= 0) return;
// Ok to add now - we've double checked position
[self addChild:projectile];
// Determine where we wish to shoot the projectile to
int realY = winSize.height + (projectile.contentSize.width/2);
float ratio = (float) offX/(float) offY;
int realX = (realY * ratio) + projectile.position.x;
CGPoint realDest = ccp(realX, realY);
// Determine the length of how far we're shooting
int offRealX = realX + projectile.position.x;
int offRealY = realY + projectile.position.y;
float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
float velocity = 480/1; // 480pixels/1sec
float realMoveDuration = length/velocity;
// Move projectile to actual endpoint
[projectile runAction:[CCSequence actions:
[CCMoveTo actionWithDuration:realMoveDuration position:realDest],
[CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)],
nil]];
//add to the projectiles array
projectile.tag = 2;
[_projectiles addObject:projectile];
} *
Ho aggiunto un fan in 3 livelli e ora il mio gioco è fantastico :) –
Puoi dirmi di più sul CONTROL_POINT – Muniraj
@TonyMac: - Possiamo usare la curva di Bezier per il tipo di movimento del proiettile. Ma nel lancio della carta ho visto che anche le dimensioni della carta variano. Come lo fai? puoi anche dirmi come possiamo implementare l'effetto di rimbalzo quando la carta collide i bordi della pattumiera? grazie – Tornado