本文整理汇总了C++中MovableObject::jump方法的典型用法代码示例。如果您正苦于以下问题:C++ MovableObject::jump方法的具体用法?C++ MovableObject::jump怎么用?C++ MovableObject::jump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MovableObject
的用法示例。
在下文中一共展示了MovableObject::jump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
//////////////////////////////////////////
/// Testing objects
//////////////////////////////////////////
ObjectFactory::get().registerClass("Object", new MovableObjectCreator());
unsigned int objectId = ObjectFactory::get().create("Object");
MovableObject *object = dynamic_cast<MovableObject*>(ObjectFactory::get().getObject(objectId));
object->jump(100, 200);
object->jump(200, 300);
ObjectMovementHandler objectMovementHandler;
objectMovementHandler.setObjects(ObjectFactory::get().getObjectMap());
EventSystem::get().setHandler(Event::Type::ObjectMove, &objectMovementHandler);
EventSystem::get().handle_events();
//////////////////////////////////////////
/// Creating window
//////////////////////////////////////////
sf::RenderWindow window(sf::VideoMode(800, 500), "Window title");
//////////////////////////////////////////
/// Testing text
//////////////////////////////////////////
/// Creating font
sf::Font font;
font.loadFromFile("arial.ttf");
/// Setups text
GraphicsText text;
text.setFont(&font);
text.setPosition(100, 100);
text.setSize(12);
text.setText("hello world");
text.setLifeTime(sf::seconds(3)); // text will disappear after 3 second
//////////////////////////////////////////
/// Testing graphic stack
//////////////////////////////////////////
std::set<GraphicsComponent*> graphicStack;
graphicStack.insert(&text);
sf::Clock clock;
while (window.isOpen()) {
clock.restart();
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
for (GraphicsComponent * gc : graphicStack) {
gc->update(clock.getElapsedTime());
gc->draw(window);
if (gc->isOver())
graphicStack.erase(gc);
}
window.display();
}
return 0;
}