onKeyPressed组合键怎么写 10C

void RenWu::AnXia(EventKeyboard::KeyCode keyc, Event* e)
{
switch (keyc)
{
case cocos2d::EventKeyboard::KeyCode::KEY_A:
MaLi_xingzou = LEFT;
{
auto animation = Animation::create();
for (int index = 24; index <= 27; index++)
{
auto str = new char[50];
std::sprintf(str, "p1_%d.png", index);
animation->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str));
}
animation->setDelayPerUnit(0.05f);

auto action = Animate::create(animation);
this->runAction(RepeatForever::create(action));
}
break;
case cocos2d::EventKeyboard::KeyCode::KEY_D:
MaLi_xingzou = RIGHT;
{

auto animation = Animation::create();
for (int index = 9; index <= 12; index++)
{
auto str = new char[50];
std::sprintf(str, "p1_%d.png", index);
animation->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str));
}
animation->setDelayPerUnit(0.05f);
auto action = Animate::create(animation);
this->runAction(RepeatForever::create(action));

}
break;
case cocos2d::EventKeyboard::KeyCode::KEY_W:
MaLi_xingzou = UP;
break;
case cocos2d::EventKeyboard::KeyCode::KEY_S:
break;

default:
break;
}
}void RenWu::update(float dt)
{

Vec2 newPos = this->getPosition();  

switch (MaLi_xingzou)
{
case STOP:
    break;
case LEFT:
    newPos.x -= SuDu_1*dt;  
    break;
case RIGHT:
    newPos.x += SuDu_1*dt;
    break;  
case UP:
    break;
case LEFTUP:
    break;
default:
    break;
}
if (!PengZhuang::getPengZhuang()->PanDuanPengZhuang(newPos))
{
    this->setPosition(newPos);
}

}

想让精灵有跳跃操作 该怎么做 求大神帮忙!!!!!!!!!!!!!!!!

1个回答

Cocos2d-x之监听键盘按住事件 https://segmentfault.com/a/1190000005804378

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问