void HelloWorld::update(float delta)
{
@H_502_1000@//判断是否按下摇杆及其类型
switch(rocker->rocketDirection)
{
case 1:
@H_502_1000@//CCLog("move @H_502_1000@%f @H_502_1000@%f", @H_502_1000@hero->getPosition().x, @H_502_1000@hero->getPosition().y);
hero->SetAnimationAdv(@H_502_1000@"run_animation.plist",@H_502_1000@"run_animation.png", @H_502_1000@"run_", 2, 8, rocker->rocketRun);
if(hero->getPosition().x+2 + hero->GetHeroSprite()->getContentSize().width/2 < visibleSize.width)
{
if( mymap->JudgeMapNotEnd(visibleSize, true))
{
if(
hero->JudgePositona(visibleSize) @H_502_1000@//hero @H_502_1000@in @H_502_1000@middle
)
{
@H_502_1000@//下面是移动地图
mymap->MoveMap(hero,visibleSize, true);
break;
}
}
@H_502_1000@//精灵没到达窗口中间位置或者地图已经移动到边缘了,精灵才可以移动,否则只播放动画
hero->setPosition(ccp(hero->getPosition().x+2,hero->getPosition().y)); @H_502_1000@//向右走
CCLog(@H_502_1000@"move @H_502_1000@right");
}
break;
case 2:
@H_502_1000@//CCLog("move @H_502_1000@%f @H_502_1000@%f", rocker->rocketRun);
if(hero->getPosition().y+2 + hero->GetHeroSprite()->getContentSize().height/2 > visibleSize.height)
{
break;
}
hero->setPosition(ccp(hero->getPosition().x, hero->getPosition().y+2)); @H_502_1000@//向上走
break;
case 3:
@H_502_1000@//CCLog("move @H_502_1000@%f @H_502_1000@%f", rocker->rocketRun);
if(hero->getPosition().x-2 - hero->GetHeroSprite()->getContentSize().width/2 > 0)
{
if( mymap->JudgeMapNotEnd(visibleSize, false))
{
if(
hero->JudgePositona(visibleSize) @H_502_1000@//hero @H_502_1000@in @H_502_1000@middle
)
{
@H_502_1000@//下面是移动地图
mymap->MoveMap(hero, false);
break;
}
}
hero->setPosition(ccp(hero->getPosition().x-2,hero->getPosition().y)); @H_502_1000@//向左走
CCLog(@H_502_1000@"move @H_502_1000@left");
}
break;
case 4:
@H_502_1000@//CCLog("move @H_502_1000@%f @H_502_1000@%f", rocker->rocketRun);
if(hero->getPosition().y-2 - hero->GetHeroSprite()->getContentSize().height/2 < 0)
{
break;
}
hero->setPosition(ccp(hero->getPosition().x,hero->getPosition().y-2)); @H_502_1000@//向下走
break;
default:
hero->StopAnimation();@H_502_1000@//停止所有动画和运动
break;
}
if(btn->isTouch)
{
if(hero->IsAttack)@H_502_1000@//英雄没在攻击
return;
hero->AttackAnimation(@H_502_1000@"attack1_animation.plist",@H_502_1000@"attack1_animation.png",@H_502_1000@"attack_",6,rocker->rocketRun);
m_pProgressView->setCurrentProgress(m_pProgressView->getCurrentProgress()-10); @H_502_1000@//更改血量
}
}