Fix pikachu
This commit is contained in:
parent
950b375609
commit
7e6c67edc9
2 changed files with 7 additions and 5 deletions
|
@ -94,9 +94,9 @@ impl DefaultMesh {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toggle(&mut self) {
|
||||
self.toggle = !self.toggle;
|
||||
if self.toggle {
|
||||
pub fn toggle(&mut self, toggle: bool) {
|
||||
self.toggle = toggle;
|
||||
if !self.toggle {
|
||||
self.mesh.texture_bind_group = Some(self.texture1_bind_group.clone());
|
||||
} else {
|
||||
self.mesh.texture_bind_group = Some(self.texture2_bind_group.clone());
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::render::{
|
|||
};
|
||||
use wgpu::util::DeviceExt;
|
||||
use winit::{
|
||||
event::{KeyboardInput, VirtualKeyCode, WindowEvent},
|
||||
event::{KeyboardInput, VirtualKeyCode, WindowEvent, ElementState},
|
||||
window::Window,
|
||||
};
|
||||
|
||||
|
@ -297,14 +297,16 @@ impl State {
|
|||
WindowEvent::KeyboardInput {
|
||||
input:
|
||||
KeyboardInput {
|
||||
state,
|
||||
virtual_keycode: Some(keycode),
|
||||
..
|
||||
},
|
||||
..
|
||||
} => {
|
||||
let is_pressed = *state == ElementState::Pressed;
|
||||
match keycode {
|
||||
VirtualKeyCode::Space => {
|
||||
self.mesh.toggle();
|
||||
self.mesh.toggle(is_pressed);
|
||||
true
|
||||
}
|
||||
_ => self.camera_controller.process_events(event),
|
||||
|
|
Loading…
Reference in a new issue