本文整理汇总了C++中Controller::button_was_pressed方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::button_was_pressed方法的具体用法?C++ Controller::button_was_pressed怎么用?C++ Controller::button_was_pressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::button_was_pressed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
InventoryImpl::update(float delta, const Controller& controller)
{
float step_angle = (2.0f * math::pi) / static_cast<float>(items.size());
if (fabsf(add_angle) > step_angle)
{
if (moving == 1)
decr_current_item();
else if (moving == -1)
incr_current_item();
moving = 0;
add_angle = 0;
}
if (controller.get_axis_state(X_AXIS) < -0.5f)
{
if (moving == 1)
{
add_angle = -step_angle + add_angle;
decr_current_item();
}
moving = -1;
}
else if (controller.get_axis_state(X_AXIS) > 0.5f)
{
if (moving == -1)
{
add_angle = step_angle + add_angle;
incr_current_item();
}
moving = 1;
}
if (moving == -1)
{
add_angle -= 3 * delta;
}
else if (moving == 1)
{
add_angle += 3 * delta;
}
if (moving == 0)
{
if (controller.button_was_pressed(OK_BUTTON) ||
controller.button_was_pressed(CANCEL_BUTTON) ||
controller.button_was_pressed(INVENTORY_BUTTON))
{
GameSession::current()->set_control_state(GameSession::GAME);
}
}
}
示例2: if
void
GeometryTest::update(float delta, const Controller& controller)
{
if (controller.button_was_pressed(ESCAPE_BUTTON) ||
controller.button_was_pressed(PAUSE_BUTTON))
{
MenuManager::display_pause_menu();
}
cursor.x += controller.get_axis_state(X_AXIS) * 500.0f * delta;
cursor.y += controller.get_axis_state(Y_AXIS) * 500.0f * delta;
cursor2.x += controller.get_axis_state(X2_AXIS) * 500.0f * delta;
cursor2.y += controller.get_axis_state(Y2_AXIS) * 500.0f * delta;
if (controller.button_was_pressed(PRIMARY_BUTTON))
{
if (point_count == 0) {
cursor = line2.p1;
cursor2 = line2.p2;
} else {
cursor = line1.p1;
cursor2 = line1.p2;
}
point_count += 1;
if (point_count > 1)
point_count = 0;
}
if (point_count == 0)
{
line1.p1 = cursor;
line1.p2 = cursor2;
}
else if (point_count == 1)
{
line2.p1 = cursor;
line2.p2 = cursor2;
}
if (line1.intersect(line2, collision_point))
{
if (!had_prev_collision)
ConsoleLog << "Collision" << std::endl;
had_prev_collision = true;
}
else
{
if (had_prev_collision)
ConsoleLog << "No Collision" << std::endl;
had_prev_collision = false;
collision_point = Vector2f(32, 32);
}
}
示例3: if
void
ParticleViewer::update(float delta, const Controller& controller)
{
for(Systems::iterator i = systems.begin(); i != systems.end(); ++i)
(*i)->update(delta);
if (!show_gui)
{
pos.x += controller.get_axis_state(X_AXIS) * delta * 100.0f;
pos.y += controller.get_axis_state(Y_AXIS) * delta * 100.0f;
if (controller.button_was_pressed(OK_BUTTON))
{
// FIXME: Disable GUI, since its crashy
// show_gui = true;
// manager->get_root()->get_focus()->set_active(true);
}
else if (controller.button_was_pressed(CANCEL_BUTTON) ||
controller.button_was_pressed(ESCAPE_BUTTON))
{
screen_manager.pop_screen();
}
}
else
{
if (!manager->get_root()->is_active())
{
show_gui = false;
}
else
{
manager->update(delta, controller);
}
}
for(ParticleSystemGUIs::iterator i = guis.begin(); i != guis.end(); ++i)
{
(*i)->update();
}
//systems[3]->set_count(count_slider->get_pos());
//systems[3]->set_velocity(velocity_slider->get_pos(), velocity_slider->get_pos());
}
示例4: fabsf
void
Conversation::update(float delta, const Controller& controller)
{
time += delta;
if (!active)
return;
grow = fabsf(sinf(time * 3.0f)) * 4.0f;
direction = Vector2f(controller.get_axis_state(X_AXIS),
controller.get_axis_state(Y_AXIS));
if (fabs(controller.get_axis_state(X_AXIS)) > 0.3f ||
fabs(controller.get_axis_state(Y_AXIS)) > 0.3f)
{
float segment = 360.0f / static_cast<float>(choices.size());
float angle = math::rad2deg(math::normalize_angle(atan2f(direction.y, direction.x) + math::pi/2.0f + math::deg2rad(segment/2.0f)));
int new_selection = int(angle / segment);
new_selection = math::mid(0, new_selection, int(choices.size()));
if (new_selection != selection) {
selection = new_selection;
// FIXME: Might be a good idea to do the woople-size per button, not globaly
grow = 0.0f;
time = 0;
}
}
else
{
selection = -1;
}
if (controller.button_was_pressed(OK_BUTTON) && selection != -1)
{
active = false;
GameSession::current()->get_pda().add_dialog("Jane",
choices[selection].topic + " - " +
choices[selection].text);
choices.clear();
GameSession::current()->set_control_state(GameSession::GAME);
ScriptManager::current()->fire_wakeup_event(ScriptManager::CONVERSATION_CLOSED);
}
}
示例5: if
void
Sprite2DView::update(float delta, const Controller& controller)
{
if (ignore_delta)
{
ignore_delta = false;
delta = 0.0f;
}
display_time += delta * 0.5f;
switch(mode) {
case SLIDESHOW:
update_slideshow(delta, controller);
break;
case MANUAL:
update_manual(delta, controller);
break;
}
if (controller.button_was_pressed(PDA_BUTTON))
{
if (shuffle)
{
std::vector<Pathname>::iterator i = std::find(directory.begin(), directory.end(),
shuffle_directory[index]);
if (i != directory.end())
{
index = i - directory.begin() ;
}
}
else
{
std::vector<Pathname>::iterator i = std::find(shuffle_directory.begin(), shuffle_directory.end(),
directory[index]);
if (i != shuffle_directory.end())
{
index = i - shuffle_directory.begin();
}
}
shuffle = !shuffle;
std::cout << shuffle << " " << index << std::endl;
}
// if (controller.button_was_pressed(INVENTORY_BUTTON))
//std::random_shuffle(shuffle_directory.begin(), shuffle_directory.end());
if (controller.button_was_pressed(TERTIARY_BUTTON))
show_thumbnail = !show_thumbnail;
if (controller.button_was_pressed(AIM_BUTTON))
{
if (mode == SLIDESHOW) mode = MANUAL;
else if (mode == MANUAL) mode = SLIDESHOW;
}
if (new_sprite)
{
fadein += delta;
if (fadein > 1.0f)
{
sprite = new_sprite;
sprite.set_alpha(1.0f);
new_sprite = Sprite();
offset = 0;
display_time = 0;
}
else
{
new_sprite.set_alpha(fadein);
}
}
}