Răsfoiți Sursa

Fixed input

Björn Ritzl 2 luni în urmă
părinte
comite
68c0b60d3a

+ 1 - 1
animation/cursor/example/cursor.script

@@ -5,7 +5,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("touch") and action.pressed then -- <3>
+	if action_id == hash("mouse_button_left") and action.pressed then -- <3>
 		self.duration = self.duration + 1 -- <4>
 		self.duration = self.duration + 1 -- <4>
 		if self.duration > 3 then  -- <5>
 		if self.duration > 3 then  -- <5>
 			self.duration = 0
 			self.duration = 0

+ 1 - 1
gui/get_set_font/example/get_set_font.script

@@ -10,7 +10,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then
+	if action_id == hash("touch") and action.pressed then
 		-- get the font file currently assigned to the font with id 'default'
 		-- get the font file currently assigned to the font with id 'default'
 		local current_font = go.get("#gui", "fonts", { key = "default" })
 		local current_font = go.get("#gui", "fonts", { key = "default" })
 
 

+ 1 - 1
gui/get_set_texture/example/get_set_texture.script

@@ -10,7 +10,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then
+	if action_id == hash("mouse_button_left") and action.pressed then
 		-- get the atlas file currently assigned to the atlas/texture with id 'ui'
 		-- get the atlas file currently assigned to the atlas/texture with id 'ui'
 		local current_atlas = go.get("#gui", "textures", { key = "ui" })
 		local current_atlas = go.get("#gui", "textures", { key = "ui" })
 
 

+ 2 - 2
movement/look_rotation/example/look_rotation.script

@@ -57,8 +57,8 @@ function update(self, dt)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	-- If the action is pressed (any key or mouse button), set the next target
-	if action.pressed then
+	-- If the left mouse button (or touch) is pressed, set the next target
+	if action_id == hash("mouse_button_left") and action.pressed then
 		next_target(self)
 		next_target(self)
 	end
 	end
 end
 end

+ 2 - 2
particles/confetti/example/confetti.script

@@ -11,7 +11,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then -- <3>
+	if action_id == hash("mouse_button_left") and action.pressed then -- <3>
 		single_shot()
 		single_shot()
 	end
 	end
 end
 end
@@ -19,5 +19,5 @@ end
 --[[
 --[[
 1. Start playing the particle effect in component "particles" in this game object.
 1. Start playing the particle effect in component "particles" in this game object.
 2. Setup timer to do a single shot of confetti every 3 seconds.
 2. Setup timer to do a single shot of confetti every 3 seconds.
-3. Play the effect on any key pressed.
+3. Play the effect when left mouse button (or touch) is pressed.
 --]]
 --]]

+ 1 - 1
particles/fireworks/example/fireworks.script

@@ -88,7 +88,7 @@ function update(self, dt)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then 
+	if action_id == hash("mouse_button_left") and action.pressed then
 		single_shot()
 		single_shot()
 	end
 	end
 end
 end

+ 1 - 1
resource/modify_atlas/example/modify_atlas.script

@@ -81,7 +81,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then
+	if action_id == hash("mouse_button_left") and action.pressed then
 		replace_atlas_image()
 		replace_atlas_image()
 	end
 	end
 end
 end

+ 2 - 2
tilemap/collisions/example/collisions.script

@@ -7,7 +7,7 @@ end
 
 
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action.pressed then
+	if action_id == hash("mouse_button_left") and action.pressed then
 		factory.create("#enemyfactory", vmath.vector3(action.x, action.y, 1))  -- <3>
 		factory.create("#enemyfactory", vmath.vector3(action.x, action.y, 1))  -- <3>
 	end
 	end
 end
 end
@@ -24,7 +24,7 @@ end
 --[[
 --[[
 1. Acquire input for the script
 1. Acquire input for the script
 2. Spawn 10 game objects at random positions near the top of the screen
 2. Spawn 10 game objects at random positions near the top of the screen
-3. Spawn a game object when any key or mouse button (or touch) is pressed
+3. Spawn a game object when the left mouse button (or touch) is pressed
 4. Something collided with the tilemap if the received message was a `collision_response`
 4. Something collided with the tilemap if the received message was a `collision_response`
 5. Check if something collided with a tile belonging to the collision group "danger"
 5. Check if something collided with a tile belonging to the collision group "danger"
 6. Delete the game object that collided with the tilemap
 6. Delete the game object that collided with the tilemap