如何在cocos2d / cocos2d-x中创建箭头拍摄功能

时间:2014-04-04 05:57:13

标签: cocos2d-x

在我的游戏中,我有一些弓箭手射箭。我已经将ccJumpBy操作当前应用于使用CCrotate操作生成的箭头。我的问题是,它看起来不那么逼真,即当它们上升时速度很快,当它们下降时速度很快但在两者之间变慢。我甚至尝试过CCEASEACTIONS,但他们开始表现的恰恰与我正在做的相反。我知道跳跃动作不能直接分成两部分。我甚至试过ccbezier的行动,但即便如此也没有帮助......这是我现在的代码。

float angle = kShootRotationAngle;
CCPoint pos = ccp(troops->getSprite()->getContentSize().width/2 + gameLayer->winSize.width * 0.48, - winSize.height * 0.15);
float jumpHeight = winSize.height * 0.28f;
if (weaponType == kArrowTypeEnemyNormal || weaponType == kArrowTypeEnemyRapid || weaponType == kArrowTypeEnemyFire) {
    angle = - kShootRotationAngle;
    pos = ccp(troops->getSprite()->getContentSize().width/2 - gameLayer->winSize.width * 0.57, - winSize.height * 0.15);
}


jumpAction = new CCJumpBy;
jumpAction->initWithDuration(kNormalArrowMovementTime, pos, jumpHeight, 1);// Allocated Memory

rotateAction = new CCRotateBy;
rotateAction->initWithDuration(kNormalArrowMovementTime, angle);// Allocated Memory

spawnActions = new CCSpawn;
spawnActions->initWithTwoActions(jumpAction, rotateAction);// Allocated memory

removeWeaponAction = CCCallFunc::create(this, callfunc_selector(Weapons::removeArrow));// AutoRelease Type

delayAction = new CCDelayTime;// Allocated memory
delayAction->initWithDuration((kFrameCountElvesShoot - 3) * kArrowShootTimeElves + delay);

showSprite = new CCFadeIn;// Allocated Memory
showSprite->initWithDuration(0.0f);

delayBeforeDeletion = new CCDelayTime; // Allocated Memory
delayBeforeDeletion->initWithDuration(kDelayBeforeArrowDestroy);

sequenceAction = new CCSequence; // Allocated Memory
sequenceAction->initWithTwoActions(delayAction, showSprite);

sequenceAction2 = new CCSequence; // Allocated Memory
sequenceAction2->initWithTwoActions(spawnActions, delayBeforeDeletion);

sequenceAction3 = new CCSequence;// Allocated memory
sequenceAction3->initWithTwoActions(sequenceAction, sequenceAction2);

sequenceAction4 = new CCSequence; // Allocated memory
sequenceAction4->initWithTwoActions(sequenceAction3, removeWeaponAction);

arrowSprite->runAction(sequenceAction4);

0 个答案:

没有答案