本文整理汇总了C++中sf::Sprite::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::SetPosition方法的具体用法?C++ Sprite::SetPosition怎么用?C++ Sprite::SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sprite
的用法示例。
在下文中一共展示了Sprite::SetPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(){
_window.Clear();
{
sf::Rect<float> frect = sf::Rect<float>(0,0,window_width,window_height);
_camera.SetFromRect(frect);
}
_window.Draw(_backgroundSprite);
// draw the range shade
_rangeSprite.SetPosition(current_pose.x + window_width/2, window_height/2 - current_pose.y);
_window.Draw(_rangeSprite);
// draw the landmarks
for(unsigned int i=0; i<landmarks.size(); i++){
_landmarkSprite.SetPosition(landmarks[i].x + window_width/2, window_height/2 - landmarks[i].y);
_window.Draw(_landmarkSprite);
}
// draw the robot
_robotSprite.SetPosition(current_pose.x + window_width/2, window_height/2 - current_pose.y);
_robotSprite.SetRotation(current_pose.theta * 180 / M_PI);
_window.Draw(_robotSprite);
// draw the "other" robot
_fakeRobotSprite.SetPosition(fake_current_pose.x + window_width/2, window_height/2 - fake_current_pose.y);
_fakeRobotSprite.SetRotation(fake_current_pose.theta * 180 / M_PI);
_window.Draw(_fakeRobotSprite);
// display everything
_window.Display();
}
示例2: main
int main()
{
img_r.LoadFromFile("..\\Imagenes\\rcircle.png");
img_b.LoadFromFile("..\\Imagenes\\bcircle.png");
sprite_b.SetImage(img_b);
sprite_r.SetImage(img_r);
sf::RenderWindow App(sf::VideoMode(800,600,32),"ventana");
const sf::Input& in = App.GetInput();
sprite_b.Scale(sprite_r.GetSize().x/sprite_b.GetSize().x,sprite_r.GetSize().y/sprite_b.GetSize().y);
while(App.IsOpened())
{
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
App.Close();
if(Event.Type == sf::Event::MouseMoved){
// cursor.SetPosition(Event.MouseMove.X,Event.MouseMove.Y);
}
}
if(in.IsKeyDown(sf::Key::Escape))
App.Close();
//cursor.SetPosition(in.GetMouseX(),in.GetMouseY());
App.Clear();
sprite_r.SetPosition(0,0);
App.Draw(sprite_r);
sprite_r.SetPosition(App.GetWidth()-img_r.GetWidth(),0);
App.Draw(sprite_r);
sprite_r.SetPosition(0,App.GetHeight()-img_r.GetHeight());
App.Draw(sprite_r);
sprite_r.SetPosition(App.GetWidth()-img_r.GetWidth(),App.GetHeight()-img_r.GetHeight());
App.Draw(sprite_r);
sprite_b.SetPosition((App.GetWidth()-sprite_b.GetSize().x)/2,(App.GetHeight()-sprite_b.GetSize().y)/2);
App.Draw(sprite_b);
App.Display();
}
return 0;
}
示例3: calculateRotation
float Functions::calculateRotation(sf::Sprite &sprite, float posX, float posY, float radius, float speed, float angle, float angleOffset)
{
float rad = (float)(angle * (3.1415 / -180));
sprite.SetPosition(posX + radius * sin(rad), posY + radius * cos(rad));
angle -= speed;
angle = fmod(angle, 360);
if (angle == 0)
{
angle = 360;
}
sprite.SetRotation(angle + angleOffset);
return angle;
}
示例4: add
void SubWindow::add(sf::Sprite sprite, sf::Vector2i pos) {
sprite.SetPosition(pos.x + position.x, pos.y + position.y);
queue.push_back(new sf::Sprite(sprite));
}