本文整理汇总了C++中Tank::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Tank::setPosition方法的具体用法?C++ Tank::setPosition怎么用?C++ Tank::setPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tank
的用法示例。
在下文中一共展示了Tank::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTank
void EnemyAI::addTank(float delta) {
static float deltaTimes = 0.0f;
deltaTimes += delta;
if(deltaTimes >= 2.0f) {
deltaTimes = 0.0f;
int count = mEnemyTanks->count();
if (count < 3) //先从固定位置添加三个坦克
{
Tank* enemyTank = Tank::createTankWithTankType(enemyTankType[count], mTileMapInfo);
enemyTank->setPosition(bornPoint[count]);
enemyTank->setRotation(180.0f);
mEnemyTanks->addObject(enemyTank);
}else if(count == 3) {
int tankTypeIndex = (int)(CCRANDOM_0_1() * 4) % 3;
Tank* enemyTank = Tank::createTankWithTankType(enemyTankType[tankTypeIndex], mTileMapInfo);
enemyTank->setPosition(bornPoint[tankTypeIndex]);
enemyTank->setRotation(180.0f);
mEnemyTanks->addObject(enemyTank);
}
}
}
示例2: main
int main()
{
network::InitializeNetwork();
initMemoryCheck();
//Init Timer
GlobalTimer *gt = GlobalTimer::getInstance();
//Init EventManager
EventManager *test;
test = myNew EventManager("test", true);
//Init ActorHandler
Actor::init();
ActorHandler *actorHandler = ActorHandler::getInstance();
network::Peer mPeer("hej2", 5002);
network::MessageHandler *msgServer, *msgClient;
msgClient = myNew network::MsgH_GameClient(&mPeer);
mPeer.getServerManager()->addMessageHandler(msgClient);
msgServer = myNew network::MsgH_GameServer("tja", mPeer.getPeerManager());
mPeer.getPeerManager()->addMessageHandler(msgServer);
mPeer.joinNetwork("localhost", 5001);
network::EventMsgHandler netEventHandler(mPeer.getIdManager());
mPeer.getPeerManager()->addMessageHandler(&netEventHandler);
//Init Listeners
EventListenerPtr snoop;
snoop = boost::shared_ptr<EventSnooper>(myNew EventSnooper());
safeAddListener(snoop, EventType(gWildcardEventType));
EventListenerPtr stats;
stats = boost::shared_ptr<Statistics>(myNew Statistics());
safeAddListener(stats, EvtData_From_ActorDestroyed::mEventType);
safeAddListener(stats, EvtData_System_EndGame::mEventType);
EventListenerPtr epActorHandler;
epActorHandler = boost::shared_ptr<ActorHandler>(actorHandler);
safeAddListener(epActorHandler,EvtData_To_EnemyUpdateHp::mEventType);
safeAddListener(epActorHandler, EvtData_From_ActorCollision::mEventType);
safeAddListener(epActorHandler, EvtData_To_TankStartFire::mEventType);
safeAddListener(epActorHandler, EvtData_To_TankStopFire::mEventType);
safeAddListener(epActorHandler, EvtData_From_ActorDestroyed::mEventType);
safeAddListener(epActorHandler, EvtData_To_ActorStartMove::mEventType);
safeAddListener(epActorHandler, EvtData_To_ActorStopMove::mEventType);
safeAddListener(epActorHandler, EvtData_To_ActorStartRotate::mEventType);
safeAddListener(epActorHandler, EvtData_To_ActorStopRotate::mEventType);
EventListenerPtr logiclol;
logiclol = boost::shared_ptr<LogicListener>(myNew LogicListener());
safeAddListener(logiclol,EvtData_From_EnemyHit::mEventType);
safeAddListener(logiclol, EvtData_System_EndGame::mEventType);
EventListenerPtr networkForwarder;
networkForwarder = boost::shared_ptr<network::EventForwarder>(myNew network::EventForwarder(&mPeer));
//safeAddListener(networkForwarder, EvtData_To_ActorStartMove::mEventType);
safeAddListener(networkForwarder, EvtData_To_ActorStopMove::mEventType);
EventListenerPtr sound;
sound = boost::shared_ptr<sound::SoundListener>(myNew sound::SoundListener());
logic::safeAddListener(sound, logic::EvtData_To_ActorStartMove::mEventType);
logic::safeAddListener(sound, logic::EvtData_To_ActorStopMove::mEventType);
logic::safeAddListener(sound, logic::EvtData_From_ActorCreated::mEventType);
logic::safeAddListener(sound, logic::EvtData_From_ActorDestroyed::mEventType);
logic::safeAddListener(sound, logic::EvtData_From_WeaponFired::mEventType);
//Init PLayerInfo
PlayerInfo *pi = PlayerInfo::getInstance();
//Init Dx
gfx::DX10Module *module = gfx::DX10Module::getInstance();
pthread_t th = module->create();
while(!module->getRunFlag())
{
Sleep(10);
}
//Init Input
logic::InputStates *input = myNew logic::InputStates(module->getHInstancePointer(), module->getHWNDPointer());
input->setState(logic::InputStates::GameState_Game_Inside_Tank);
//testing dxmodule
module->lock(0);
gfx::Camera *camera = module->getCamera();
camera->setTarget(D3DXVECTOR3(0.0f, 0.0f, 0.0f));
camera->setPosition(D3DXVECTOR3(-100.0f, 50.0f, -100.0f));
module->loadObjectShapeInstance(gfx::ShapeTypes::CUBE, 1, "Cube", 5000);
srand(time(0));
int colorCounter;
gfx::TransformObject *tempObj;
//.........这里部分代码省略.........