本文整理汇总了C++中Platform::getPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::getPos方法的具体用法?C++ Platform::getPos怎么用?C++ Platform::getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::getPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void Pickup::Update(float dt, XNA::AxisAlignedBox *player, World* w)
{
Platform* p = w->getPlatform(this->getCPID());
if(p != NULL)
{
XMFLOAT3 pos = p->getPos();
pos.x += this->mPos.x;
pos.y += this->mPos.y;
pos.z += this->mPos.z;
mEntity->SetPosition(pos);
this->mSphere.Center = pos;
}
if(XNA::IntersectSphereAxisAlignedBox(&mSphere, player))
{
struct Data
{
int id; //dummy
};
Data* data = new Data;
data->id = this->mID;
Network::GetInstance()->Push(new Package(Package::Header(9, this->mID, sizeof(Data)), Package::Body((char*)(data))));
}
}
示例2: Update
void Editor::Update() {
if ( myKeys[sf::Keyboard::Back].pressed ) {
myStage->getArea(0)->Clear();
myNextScreen = ScreenMenu;
}
sf::Vector2i mouseCell((int)myMouse.x/32,(int)myMouse.y/32);
myGUI->Update( myMouse );
/*
* Mouse is on GUI
*/
if ( myGUI->onGUI() ) {
/*
* TOOLBAR
*/
if ( myGUI->getGUI( ) == myToolBar ) {
if ( myMouseLeft && myGUI->onWidget() && myGUI->getWidget()->getType() == widget_button ) {
Button * btn = static_cast<Button*>(myGUI->getWidget());
if ( myBrush == btn->getValue() ) myBrush = brush_null;
else switch(btn->getValue() ) {
case brush_platform:
case brush_enemy:
case brush_spawn: {
myBrush = btn->getValue();
break;
}
case action_save: {
myStage->Save();
myAlert->setText("Map saved...");
myAlert->Display();
break;
}
case action_load: {
myStage->Load();
myAlert->setText("Map loaded...");
myAlert->Display();
break;
}
}
}
}
}
/*
* Otherwise
*/
else {
if ( myBrush != brush_null ) myPlatformHelper.SetPosition( mouseCell.x*32, mouseCell.y*32);
// =========================================================================================
// Brush: Platform
// =========================================================================================
if ( myBrush == brush_platform ) {
if ( !myPlatform) {
if ( myMouseLeft ) {
int erase = 0;
Area * a = myStage->getArea(0);
for( vector<Platform*>::iterator it = a->myPlatforms.begin(); it != a->myPlatforms.end(); ++it) {
Platform * p = *it;
if ( p->getPos().x > myMouse.x || p->getPos().x + p->getSize().x < myMouse.x ||
p->getPos().y > myMouse.y || p->getPos().y + p->getSize().y < myMouse.y ) continue;
delete p;
a->myPlatforms.erase(it);
erase = 1;
break;
}
if ( !erase ) {
Platform * p = new Platform();
myPlatform = p;
p->setPos( sf::Vector2f(mouseCell.x*32, mouseCell.y*32) );
myCell = mouseCell;
a->myPlatforms.push_back(p);
}
}
}
else {
if ( myMouseLeftDown ) {
int x_dif = mouseCell.x - myCell.x;
int y_dif = mouseCell.y - myCell.y;
if ( x_dif < 0 ) {
myPlatform->setX( myCell.x*32+x_dif*32 );
x_dif = -x_dif;
}
else myPlatform->setX( myCell.x*32);
if ( y_dif < 0 ) {
myPlatform->setY( myCell.y*32+y_dif*32 );
y_dif = -y_dif;
}
else myPlatform->setY( myCell.y*32);
//.........这里部分代码省略.........