int MyHero::walk_right() { if (_frame_status == 0) { _frame_status = 1; _frame->getAnimation()->playWithIndex(_frame_status); } if (_frame_status == 1) { _frame->setScaleX(1); x = getPositionX(); if (x < 850) { setPosition(x + 8, getPositionY()); return false; } return true; } return false; }
void Projectile::update() { if (abs(getPositionX() - initialX) > MAX_TRAVEL_DISTANCE || abs(getPositionY() - initialY) > MAX_TRAVEL_DISTANCE || ticksSinceCreation > PROJECTILE_MAX_DURATION) Engine::getInstance().markObjectForRemoval(this); else if (myBody != NULL) move(facingPosition); ++ticksSinceCreation; }
void Sprite::DrawTexture() { glPushMatrix(); // Translate glTranslatef(getPositionX(), getPositionY(), 0); // Rotate on the Z axis glRotatef(getRotation(), 0.0f, 0.0f, 1.0f); // Scale glScalef(scaleX, scaleY, 0); // Tell OpenGL we're drawing a quad glBegin(GL_QUADS); // Bottom-left vertex (corner) glTexCoord2f(bounds.x / width, bounds.y / height); glVertex3f(-(bounds.w / 2), -(bounds.h / 2), 0); // Bottom-right vertex (corner) glTexCoord2f((bounds.x + bounds.w) / width, bounds.y / height); glVertex3f((bounds.w / 2), -(bounds.h / 2), 0); // Top-right vertex (corner) glTexCoord2f((bounds.x + bounds.w) / width, (bounds.y + bounds.h) / height); glVertex3f((bounds.w / 2), (bounds.h / 2), 0); // Top-left vertex (corner) glTexCoord2f(bounds.x / width, (bounds.y + bounds.h) / height); glVertex3f(-(bounds.w / 2), (bounds.h / 2), 0); glEnd(); glPopMatrix(); }
void InstallationObjectImplementation::setActiveResource(ResourceContainer* container) { Time timeToWorkTill; if (resourceHopper.size() == 0) { addResourceToHopper(container); currentSpawn = container->getSpawnObject(); spawnDensity = currentSpawn->getDensityAt(getZone()->getZoneName(), getPositionX(), getPositionY()); return; } updateInstallationWork(); int i = 0; for (; i < resourceHopper.size(); ++i) { ResourceContainer* entry = resourceHopper.get(i); if (entry == container) { if (i == 0) return; ManagedReference<ResourceContainer*> oldEntry = resourceHopper.get(0); InstallationObjectDeltaMessage7* inso7 = new InstallationObjectDeltaMessage7( _this.get()); inso7->updateHopper(); inso7->startUpdate(0x0D); resourceHopper.set(0, container, inso7, 2); if(oldEntry->getQuantity() > 0) resourceHopper.set(i, oldEntry, inso7, 0); else resourceHopper.remove(i, inso7, 0); currentSpawn = container->getSpawnObject(); spawnDensity = currentSpawn->getDensityAt(getZone()->getZoneName(), getPositionX(), getPositionY()); inso7->updateHopperSize(getHopperSize()); inso7->updateExtractionRate(getActualRate()); inso7->close(); broadcastToOperators(inso7); } } }
bool Polygon::init(PolygonInfo& polygonInfo) { if (Sprite::init()) { _type = Polygon_; setTag(polygonInfo.tag); this->isConvex = polygonInfo.isConvex; setPosition(polygonInfo.position.x*DefiniteSize.width, polygonInfo.position.y*DefiniteSize.height); GameManager* gameManager = GameManager::getInstance(); b2BodyDef bodyDef; bodyDef.type = b2_staticBody; bodyDef.position = cc_to_b2Vec(getPositionX() + (VisibleSize.width/2 - DefiniteSize.width/2), getPositionY()); bodyDef.userData = this; _body = gameManager->getBox2dWorld()->CreateBody(&bodyDef); b2FixtureDef fixtureDef; fixtureDef.filter.groupIndex = -1; fixtureDef.filter.categoryBits = 0; fixtureDef.filter.maskBits = 0; b2PolygonShape shape; int vertexCount = polygonInfo.vertexes.size(); CCASSERT(vertexCount>=3&&vertexCount<=b2_maxPolygonVertices, "vertex count is too little or too much!"); b2Vec2 points[b2_maxPolygonVertices]; if (isConvex) { for (int i = 0; i<vertexCount; i++) { points[i] = cc_to_b2Vec(polygonInfo.vertexes[i].x, polygonInfo.vertexes[i].y); } shape.Set(points,vertexCount); fixtureDef.shape = &shape; _body->CreateFixture(&fixtureDef); }else{ // std::vector<b2Vec2> vertexes; for (Vec2 vertex : polygonInfo.vertexes) { b2Vec2 point = cc_to_b2Vec(vertex.x, vertex.y); vertexes.push_back(point); } //切割 b2Separator* separator = new b2Separator(); if (separator->Validate(vertexes)==0) { separator->Separate(_body, &fixtureDef, &vertexes, PTM_RATIO); }else if (separator->Validate(vertexes)==1){ CCASSERT(0==1, "there are overlapping lines!"); }else if (separator->Validate(vertexes)==2){ CCASSERT(0==2, "the points are not in clockwise order"); }else if (separator->Validate(vertexes)==3){ CCASSERT(0==3, "there are overlapping lines and the points are not in clockwise order"); } CC_SAFE_DELETE(separator); } return true; } return false; }
CCRect RCDPad::rect() { float scaleMod = 1.5f; float w = getContentSize().width * getScale() * scaleMod; float h = getContentSize().height * getScale() * scaleMod; CCPoint point = CCPointMake(getPositionX() - (w/2), getPositionY() - (h/2)); return CCRectMake(point.x, point.y, w, h); }
void Hero::initBlock() { m_block = CCRectMake( getPositionX(), getPositionY(), m_sprite->getContentSize().width - 5, m_sprite->getContentSize().height); }
void Block::moveDown() { this->index --; CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); runAction(CCSequence::create(CCMoveTo::create(0.1,ccp(getPositionX(),visibleSize.height/4 *index)),CCCallFunc::create(this,callfunc_selector(Block::clean)),NULL)); }
void Ball::move(){ setPositionX(getPositionX()+speedX); setPositionY(getPositionY()+speedY); if (getPositionX()<r) { speedX = MABS(speedX); } if (getPositionY()<r) { speedY = MABS(speedY); } if (getPositionX()>boundWidth-r) { speedX = -MABS(speedX); } if (getPositionY()>boundHeight-r) { speedY = -MABS(speedY); } }
void DormScene::DeskPressed(cocos2d::Ref *pSender) { log("You touched the desk!"); // get the character and desk positions auto character = this->getScene()->getChildByName<SpriteBatchNode*>("test")->getChildByName<Sprite*>("bill"); auto desk = this->getScene()->getChildByName<DormScene*>("dorm")->getChildByName("menu")->getChildByName<cocos2d::Sprite*>("desk"); float destination = desk->getPositionX(); // get the character's sprite position float start = character->getPositionX(); // move the character there Movement::moveCharacter(this->getScene(), start, destination); }
void Plane::update(float dt) { setPositionX(getPositionX()+speedX); if (getScaleX()>0) { if (getPositionX()<-getContentSize().width) { unscheduleUpdate(); planes->removeObject(this); getParent()->removeChild(this); } } else { if (getPositionX()>visibleSize.width+getContentSize().width) { unscheduleUpdate(); planes->removeObject(this); getParent()->removeChild(this); } } }
bool MoneyLayer::init(){ if (!Layer::init()){ return false; } this->scheduleUpdate(); auto moneyBG = Sprite::create("herodetail-detail.png"); moneyBG->setPosition(vSize.width / 3, (vSize.height / 15) * 14); moneyBG->setScale(1.4, 0.7); moneyBG->setOpacity(160); this->addChild(moneyBG); auto diamondBG = Sprite::create("herodetail-detail.png"); diamondBG->setPosition(vSize.width / 3 * 2, (vSize.height / 15) * 14); diamondBG->setScale(1.4, 0.7); diamondBG->setOpacity(160); this->addChild(diamondBG); auto money = Sprite::create("task_gold_icon_.png"); money->setPosition(moneyBG->getPositionX() + 120, moneyBG->getPositionY()); money->setScale(0.7, 0.7); this->addChild(money); auto diamond = Sprite::create("task_rmb_icon_.png"); diamond->setPosition(diamondBG->getPositionX() + 120, diamondBG->getPositionY()); diamond->setScale(0.7, 0.7); this->addChild(diamond); auto item = MenuItemImage::create("main_status_plus_icon_.png", "main_status_plus_icon_.png", CC_CALLBACK_1(MoneyLayer::money, this)); item->setScale(0.7, 0.7); auto menu = Menu::create(item, NULL); menu->setPosition(moneyBG->getPositionX() - 120, moneyBG->getPositionY()); this->addChild(menu); auto addd = Sprite::create("main_status_plus_icon_.png"); addd->setPosition(diamondBG->getPositionX() - 120, diamondBG->getPositionY()); addd->setScale(0.7, 0.7); this->addChild(addd); auto strMoney = StringUtils::format("%d", RoleAmrature::getInstance()->getRoleMoney()); auto label = Label::create(strMoney, "Arial", 30); label->setName("label"); label->setPosition(moneyBG->getPositionX() , moneyBG->getPositionY()); this->addChild(label); return true; }
void GameObjHero::releaseBullet(float f) { if(isControl) { GameMain* p = (GameMain*)this->getParent(); p->releaseHeroBullets(getPositionX(),getPositionY() + 30); } }
void MyMap::right() { x = getPositionX(); if (x > -1300) { setPositionX(x - 8); } }
void Enemy03::setPoint(float dt) { auto target = static_cast<Player*>(getTarget()); if( getPositionY() > (winSize.height * 0.7)){ this->setPosition(getPositionX(), (getPositionY()-5)); } else if( getPositionY() <= (target->getPositionY()) ){ this->setPosition(target->getPositionX(), (getPositionY()-10)); } else{ auto x = target->getPositionX() - getPositionX(); auto minus = 0; if(x < 0){ x=x*-1; minus = 1; } if(x > 5){ if(minus==1){ this->setPosition((getPositionX()-10), (getPositionY()-8)); }else{ this->setPosition((getPositionX()+10), (getPositionY()-8)); } }else{ this->setPosition(target->getPositionX(), (getPositionY()-5)); } } }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); // auto bg = Sprite::createWithSpriteFrameName("bg.png"); // bg->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // this->addChild(bg); // auto panel = Sprite::create("panel.png"); // panel->setPosition(bg->getPosition()); // panel->setScaleX(1.5); // panel->setScaleY(2); // this->addChild(panel); float margin = 40.0f; auto appname = cocos2d::ui::Text::create(LHLocalizedCString("appname"), Common_Font, 50); appname->setColor(Color3B::BLACK); appname->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + appname->getContentSize().height/2 + margin + origin.y)); this->addChild(appname); auto play = ui::Button::create("play.png"); play->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 - play->getContentSize().height/2 - margin + origin.y)); play->addTouchEventListener([](Ref *ps,ui::Widget::TouchEventType type){ if (type == ui::Widget::TouchEventType::ENDED) { Director::getInstance()->replaceScene(PlayScene::createScene(nullptr)); } }); this->addChild(play); auto debt = DeveloperInfo::DevInfoButton("devinfo.png"); debt->setPosition(Vec2(appname->getPositionX() + appname->getContentSize().width/2 + 40, appname->getPositionY() + appname->getContentSize().height/2 + 20)); this->addChild(debt); auto leader = LHLeaderBoard::defaultButton("lb.png"); leader->setPosition(Vec2(visibleSize.width/3*2 + origin.x, visibleSize.height/4 + origin.y)); this->addChild(leader); auto goReview = ui::Button::create("goreview.png"); goReview->setPosition(Vec2(visibleSize.width/3 + origin.x, visibleSize.height/4 + origin.y)); goReview->addTouchEventListener([](Ref *ps,ui::Widget::TouchEventType type){ if (type == ui::Widget::TouchEventType::ENDED) { ThirdPartyHelper::goReview(); } }); this->addChild(goReview); return true; }
/** @brief キャンバス初期化 @param[in] なし @return なし */ void RelayGameLayer::_NextCanvas() { auto oldCanvas = this->getChildByName("Canvas"); //----------------------------------------------------- // 新規キャンバスを既存キャンバスの下に auto layerCanvas = LayerCanvas::create(); if (layerCanvas && layerCanvas->createSprite("canvas.png")) { this->addChild(layerCanvas, oldCanvas->getLocalZOrder()-1, "NewCanvas"); layerCanvas->setPosition(oldCanvas->getPosition()); //layerCanvas->setVisible(false); } //----------------------------------------------------- // DrawNode auto drawNode = DrawNode::create(); { drawNode->setAnchorPoint(Vec2::ZERO); auto canvas = layerCanvas->getSprite(); //layerCanvas->addChild(m_pDrawNode, 1); drawNode->setPosition( -(layerCanvas->getPositionX() - layerCanvas->getAnchorPoint().x*layerCanvas->getContentSize().width), -(layerCanvas->getPositionY() - layerCanvas->getAnchorPoint().y*layerCanvas->getContentSize().height) ); canvas->addChild(drawNode, 1, "DrawNode"); } oldCanvas->runAction( Sequence::create( PageTurn3D::create(0.5f, Size(24.f, 32.f)), CallFunc::create([this, oldCanvas, layerCanvas, drawNode](){ // キャンバスの入れ替え //this->removeChild(oldCanvas); oldCanvas->setName(oldCanvas->getName() + std::to_string(m_nowPage)); oldCanvas->setVisible(false); layerCanvas->setLocalZOrder(ZOrder::CANVAS); layerCanvas->setName("Canvas"); //-------------------------- // DrawNode入れ替え //m_pDrawNode->release(); m_pDrawNode = drawNode; //-------------------------- // ページ追加 m_nowPage++; m_touchPoints.push_back(page_t()); m_nowLine = 0; //-------------------------- // 解答ボックス初期化 m_pEditBox->setText(""); }), nullptr ) ); }
void MyMap::left() { x = getPositionX(); if (x < 0) { setPositionX(x + 8); } }
// 在StarMatrix中调用 void Star::updatePosition() { // 判断当前位置与目标位置desPosition是否相同 if (desPosition.y != getPositionY()) { // 逐渐改变Star的position,使之逐渐移动到desPosition setPositionY(getPositionY() - MOVE_SPEED); if (getPositionY() < desPosition.y) { setPositionY(desPosition.y); } } if (desPosition.x != getPositionX()) { setPositionX(getPositionX() - MOVE_SPEED); if(getPositionX() < desPosition.x) { setPositionX(desPosition.x); } } }
CCRect Plant::myBoundingBox() { CCSize size = m_sprite->getContentSize(); return CCRectMake( getPositionX()-size.width/2, getPositionY()-size.height/2, size.width, size.height); }
void Shuriken::update(float frameTime){ Entity::update(frameTime); setRadians(getRadians()+0.05); //update position based on velocity changes incPosition(D3DXVECTOR2(velocity*frameTime)); //apply new position spriteData.x = getPositionX(); spriteData.y = getPositionY(); }
void Ignite::runAction() { auto particle = getParticle(); auto invoke = ScaleTo::create(0.2f, 0.3f); FiniteTimeAction* actionCompleted = CallFuncN::create(CC_CALLBACK_1(Ignite::onActionCompletedThenRemove, this)); particle->setPosition(getPositionX(), getPositionY()); getParent()->addChild(particle); particle->runAction(Sequence::create(invoke, actionCompleted, nullptr)); }
bool HeroEnety::judgeIfAttainBase() { float posX = getPositionX(); if (posX >= _limitPosLeft && posX <= _limitPosRight) { return false; } attainBase(posX < _limitPosLeft ? RaceEunm::Red :RaceEunm::Blue); GoDead(); return true; }
void BackGround::resetPos(cocos2d::Layer* layer, const Tags tag){ auto sprite = (Sprite*)layer->getChildByTag(tag); auto follow = (CustomAction::CustomFollow*)layer->getActionByTag(FOLLOW); /*if (sprite->getPosition().x + Director::getInstance()->getWinSize().width < layer->getPositionX() ){ sprite->setPosition(Vec2(sprite->getPositionX() + Director::getInstance()->getWinSize().width * 2, sprite->getPositionY())); }*/ int layerPos = layer->getPositionX() * -1; int WinsizeX = Director::getInstance()->getWinSize().width; if (layerPos == 0) return; if (layerPos > sprite->getPositionX() + 1800){ sprite->setPosition(Vec2(sprite->getPositionX() + 1800 * 2, sprite->getPositionY())); } }
void BBat::spawnBBat(cocos2d::Layer * layer,float x,float y) { auto Bat=cocos2d::Sprite::create("Bat (1).png"); auto ran=CCRANDOM_0_1(); auto posi_x=ran*(visibleSize.width)+origin.x; auto posi_y=origin.y+visibleSize.height+Bat->getContentSize().height; Vector<SpriteFrame*> an(4); an.pushBack(SpriteFrame::create("Bat (1).png", Rect(0,0,174,118))); an.pushBack(SpriteFrame::create("Bat (2).png", Rect(0,0,174,118))); an.pushBack(SpriteFrame::create("Bat (3).png", Rect(0,0,174,118))); an.pushBack(SpriteFrame::create("Bat (4).png", Rect(0,0,174,118))); auto ann=Animation::createWithSpriteFrames(an,0.1f); auto anim_ll=Animate::create(ann); auto anim_l=RepeatForever::create(anim_ll); anim_l->setTag(1); Bat->runAction(anim_l); auto size=Bat->getContentSize(); //size.width=size.width*0.8; //size.height=size.height*0.8; auto body=cocos2d::PhysicsBody::createCircle(size.height/4); body->setDynamic(false); body->setCollisionBitmask(BBAT_COLLISION_BITMASK); body->setContactTestBitmask(BBAT_CONTACT_BITMASK); Bat->setPhysicsBody(body); Bat->setPosition(Point(posi_x,posi_y)); layer->addChild(Bat,105); auto move_dis=Bat->getContentSize().height+visibleSize.height*0.14; auto move_duration=BBAT_SPEED*move_dis; auto Bat_move=cocos2d::MoveBy::create(move_duration,Point(0,-move_dis)); auto Bat_pause=cocos2d::DelayTime::create(1.5f); auto Bat_pause2=cocos2d::DelayTime::create(0.5f); auto attack_dis=sqrt((x-Bat->getPositionX())*(x-Bat->getPositionX())+(y-Bat->getPositionY())*(y-Bat->getPositionY())); auto attack_duration=BBAT_SPEED*move_dis; auto Bat_attack=cocos2d::MoveTo::create(attack_duration, Point(x,y)); Bat->runAction(Sequence::create(Bat_move,Bat_pause,Bat_attack,Bat_pause2,RemoveSelf::create(true),nullptr)); }
void Ball::beStop() { SpriteBase::beStop(); // setPositionY((int)(getPositionY()/paopaoHeight)*paopaoHeight); float height=CCDirector::sharedDirector()->getWinSize().height; // //int addY=(int)getPositionY()%paopaoHeight; // int addY= (int)(height-getPositionY())%paopaoHeight; // CCLog("addY=%i",addY); // if (addY==0) { // setPositionY(getPositionY()+addY); // }else{ // setPositionY(getPositionY()+addY-paopaoHeight); // } int lineNum=(int)((height-getPositionY())/paopaoHeight); if (((int)(height-getPositionY())%paopaoHeight)>paopaoHeight*0.1) { lineNum++; } CCLog("n=%i",lineNum); setPositionY(height-paopaoWidth*lineNum); if (mainLayer!=NULL) { GameLayer *gl=(GameLayer *)mainLayer; bool isFull=(int)(getPositionY()/paopaoHeight)%2==0?!gl->firstLineIsFull:gl->firstLineIsFull; int nn=0; if (((int)getPositionX()%paopaoWidth)>paopaoWidth*0.5) { nn=1; } if (isFull) { setPositionX((0.5+nn+(int)(getPositionX()/paopaoWidth))*paopaoWidth); }else{ setPositionX((nn+(int)(getPositionX()/paopaoWidth))*paopaoWidth); } } }
int Creature::FaceX() { int Temp; Temp = 0; if (getDirection() == 2) { Temp = -1; } else if (getDirection() == 3) { Temp = 1; } return (getPositionX()+Temp); }
void SportsLayer::drawMyself(){ NetPalyermsg msgp=NetmsgManger::getNetManager()->msgNet; vector<RankingData> m_v=RankingListHelper::getHelper()->getOneGroupRankingList(msgp.cur_group); float width=Actual_x*0.8f; float hight=Actual_y*0.8f; int fontsize=22; if(vsion==1){ width=Actual_x*0.8f; hight=Actual_y*0.8f; }else if(vsion==2){ width=525; hight=450; fontsize=20; } for(size_t i=0;i<m_v.size();i++){ string numbers=__String::createWithFormat("%d",m_v.at(i).rankId)->getCString(); if(i<3){ numbers=__String::createWithFormat("%d",m_v.at(i).rankId)->getCString(); }else{ string sr=__String::createWithFormat("number%d",(i+1))->getCString(); numbers=FX::StringsMap::getValue(sr); } auto number=Label::createWithSystemFont(numbers,"Arial",fontsize); number->setColor(Color3B(0,0,0)); number->setPosition(Vec2(width*0.08+number->getContentSize().width/2,hight*(0.52-i*0.07))); l_one->addChild(number); //ImageHelper::getUnitSpriteRunningScene(m_v.at(i).bonus_unitId); auto warld_mc=Sprite::create("ui_icon_jinbi.png"); warld_mc->setPosition(Vec2(width*0.7,hight*(0.52-i*0.07))); warld_mc->setScale(0.7f); l_one->addChild(warld_mc); auto number1=Label::createWithSystemFont(__String::createWithFormat("%d",m_v.at(i).bonusCount)->getCString(),"Arial",fontsize); number1->setColor(Color3B(0,0,0)); number1->setPosition(Vec2(warld_mc->getPositionX()+warld_mc->getContentSize().width/2+20+number1->getContentSize().width/2,hight*(0.52-i*0.07))); l_one->addChild(number1); } }
void Obstacle::render() { glPushMatrix(); glTranslatef(getPositionX()-SIZE/2,getPositionY()-SIZE/2,getPositionZ()-SIZE/2); glColor4f(1, 0, 0, 1); glBegin(GL_QUADS); // Front Face glVertex3f(Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); // Back Face glVertex3f(Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); // Top Face glVertex3f(Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); // Bottom Face glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); // Left face glVertex3f(Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); glVertex3f(Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); // Right face glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,-Obstacle::SIZE); glVertex3f(-Obstacle::SIZE,-Obstacle::SIZE,Obstacle::SIZE); glEnd(); glPopMatrix(); }
void EnemyTest::changeDirection(float dt) { auto curr = currPoint(); if (curr->getPositionX() > this->getPosition().x) { sprite->runAction(Animate::create(AnimationCache::getInstance()->getAnimation("monster1_right"))); //从cache里取出动画播放 } else{ sprite->runAction(Animate::create(AnimationCache::getInstance()->getAnimation("monster1_left"))); } }