mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 05:33:04 +00:00
Resolve comments
This commit is contained in:
parent
0ed7917f4f
commit
9126b38363
3 changed files with 25 additions and 27 deletions
|
@ -210,7 +210,17 @@ where
|
|||
|
||||
/// Returns `true` if any item in `inputs` has just been released.
|
||||
pub fn any_just_released(&self, inputs: impl IntoIterator<Item = T>) -> bool {
|
||||
inputs.into_iter().any(|it| self.just_released(it))
|
||||
inputs.into_iter().any(|input| self.just_released(input))
|
||||
}
|
||||
|
||||
/// Returns `true` if all items in `inputs` have just been released.
|
||||
pub fn all_just_released(&self, inputs: impl IntoIterator<Item = T>) -> bool {
|
||||
inputs.into_iter().all(|input| self.just_released(input))
|
||||
}
|
||||
|
||||
/// Returns `true` if all items in `inputs` have been just pressed.
|
||||
pub fn all_just_pressed(&self, inputs: impl IntoIterator<Item = T>) -> bool {
|
||||
inputs.into_iter().all(|input| self.just_pressed(input))
|
||||
}
|
||||
|
||||
/// Clears the `just_released` state of the `input` and returns `true` if the `input` has just been released.
|
||||
|
|
|
@ -414,16 +414,12 @@ impl Gamepad {
|
|||
|
||||
/// Returns `true` if any item in the [`GamepadButton`] iterator has been pressed.
|
||||
pub fn any_pressed(&self, button_inputs: impl IntoIterator<Item = GamepadButton>) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.any(|button_type| self.pressed(button_type))
|
||||
self.digital.any_pressed(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if all items in [`GamepadButton`] have been pressed.
|
||||
/// Returns `true` if all items in the [`GamepadButton`] iterator have been pressed.
|
||||
pub fn all_pressed(&self, button_inputs: impl IntoIterator<Item = GamepadButton>) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.all(|button_type| self.pressed(button_type))
|
||||
self.digital.all_pressed(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if the [`GamepadButton`] has been pressed during the current frame.
|
||||
|
@ -433,18 +429,14 @@ impl Gamepad {
|
|||
self.digital.just_pressed(button_type)
|
||||
}
|
||||
|
||||
/// Returns `true` if any item in [`GamepadButton`] has been pressed during the current frame.
|
||||
/// Returns `true` if any item in the [`GamepadButton`] iterator has been pressed during the current frame.
|
||||
pub fn any_just_pressed(&self, button_inputs: impl IntoIterator<Item = GamepadButton>) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.any(|button_type| self.just_pressed(button_type))
|
||||
self.digital.any_just_pressed(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if all items in [`GamepadButton`] have been just pressed.
|
||||
/// Returns `true` if all items in the [`GamepadButton`] iterator have been just pressed.
|
||||
pub fn all_just_pressed(&self, button_inputs: impl IntoIterator<Item = GamepadButton>) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.all(|button_type| self.just_pressed(button_type))
|
||||
self.digital.all_just_pressed(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if the [`GamepadButton`] has been released during the current frame.
|
||||
|
@ -454,24 +446,20 @@ impl Gamepad {
|
|||
self.digital.just_released(button_type)
|
||||
}
|
||||
|
||||
/// Returns `true` if any item in [`GamepadButton`] has just been released.
|
||||
/// Returns `true` if any item in the [`GamepadButton`] iterator has just been released.
|
||||
pub fn any_just_released(
|
||||
&self,
|
||||
button_inputs: impl IntoIterator<Item = GamepadButton>,
|
||||
) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.any(|button_type| self.just_released(button_type))
|
||||
self.digital.any_just_released(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if all items in [`GamepadButton`] have just been released.
|
||||
/// Returns `true` if all items in the [`GamepadButton`] iterator have just been released.
|
||||
pub fn all_just_released(
|
||||
&self,
|
||||
button_inputs: impl IntoIterator<Item = GamepadButton>,
|
||||
) -> bool {
|
||||
button_inputs
|
||||
.into_iter()
|
||||
.all(|button_type| self.just_released(button_type))
|
||||
self.digital.all_just_released(button_inputs)
|
||||
}
|
||||
|
||||
/// Returns an iterator over all digital [button]s that are pressed.
|
||||
|
|
|
@ -393,12 +393,12 @@ fn update_buttons(
|
|||
materials: Res<ButtonMaterials>,
|
||||
mut query: Query<(&mut MeshMaterial2d<ColorMaterial>, &ReactTo)>,
|
||||
) {
|
||||
for buttons in &gamepads {
|
||||
for gamepad in &gamepads {
|
||||
for (mut handle, react_to) in query.iter_mut() {
|
||||
if buttons.just_pressed(**react_to) {
|
||||
if gamepad.just_pressed(**react_to) {
|
||||
*handle = materials.active.clone();
|
||||
}
|
||||
if buttons.just_released(**react_to) {
|
||||
if gamepad.just_released(**react_to) {
|
||||
*handle = materials.normal.clone();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue