Browse Source

Changed from "click" to "touch" to better map with template projects

Björn Ritzl 6 years ago
parent
commit
629267225a

+ 1 - 1
examples/_main/menu.gui_script

@@ -137,7 +137,7 @@ function on_message(self, message_id, message, sender)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then
+	if action_id == hash("touch") and action.pressed then
 		if self.state == "categories" then
 		if self.state == "categories" then
 			for i, cat in ipairs(self.categories) do
 			for i, cat in ipairs(self.categories) do
 				if gui.pick_node(cat.node, action.x, action.y) then
 				if gui.pick_node(cat.node, action.x, action.y) then

+ 1 - 1
examples/_main/ui.gui_script

@@ -14,7 +14,7 @@ function on_message(self, message_id, message, sender)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed and self.active then
+	if action_id == hash("touch") and action.pressed and self.active then
 		if gui.pick_node(self.closenode, action.x, action.y) then
 		if gui.pick_node(self.closenode, action.x, action.y) then
 			msg.post("/loader#script", "unload_example")
 			msg.post("/loader#script", "unload_example")
 		end
 		end

+ 1 - 1
examples/animation/spine/spine.script

@@ -4,7 +4,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then
+	if action_id == hash("touch") and action.pressed then
     	local properties = { blend_duration = 0.3 } -- <3>
     	local properties = { blend_duration = 0.3 } -- <3>
     	if self.state == "idle" then -- <4>
     	if self.state == "idle" then -- <4>
 			spine.play_anim("#spinemodel", hash("run"), go.PLAYBACK_LOOP_FORWARD, properties)
 			spine.play_anim("#spinemodel", hash("run"), go.PLAYBACK_LOOP_FORWARD, properties)

+ 2 - 2
examples/basics/follow/follow.script

@@ -8,7 +8,7 @@ local function landed(self) -- <9>
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-    if action_id == hash("click") and action.pressed then -- <3>
+    if action_id == hash("touch") and action.pressed then -- <3>
 		if not self.moving then -- <4>
 		if not self.moving then -- <4>
 			msg.post("#label", "disable") -- <5>
 			msg.post("#label", "disable") -- <5>
 			self.moving = true -- <6>
 			self.moving = true -- <6>
@@ -21,7 +21,7 @@ end
 --[[
 --[[
 1. Tell the engine that this game object ("." is shorthand for the current game object) should listen to input. Any input will be received in the `on_input()` function.
 1. Tell the engine that this game object ("." is shorthand for the current game object) should listen to input. Any input will be received in the `on_input()` function.
 2. Store a flag in `self` (the current script component) to indicate if the game object is moving or not.
 2. Store a flag in `self` (the current script component) to indicate if the game object is moving or not.
-3. If we receive an input action named "click" and it is pressed then run the following.
+3. If we receive an input action named "touch" and it is pressed then run the following.
 4. If the `moving` flag is not set.
 4. If the `moving` flag is not set.
 5. Disable (don't show) the help text label.
 5. Disable (don't show) the help text label.
 6. Set the `moving` flag.
 6. Set the `moving` flag.

+ 1 - 1
examples/basics/message_passing/bunny2.script

@@ -24,7 +24,7 @@ function on_message(self, message_id, message, sender)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed and not self.moving then -- <3>
+	if action_id == hash("touch") and action.pressed and not self.moving then -- <3>
 		local pos = vmath.vector3(action.x, action.y, 0)
 		local pos = vmath.vector3(action.x, action.y, 0)
 		msg.post("#", "go to", { position = pos }) -- <4>
 		msg.post("#", "go to", { position = pos }) -- <4>
 	end
 	end

+ 1 - 1
examples/basics/parent_child/parent.script

@@ -9,7 +9,7 @@ end
 
 
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-    if action_id == hash("click") and action.pressed then
+    if action_id == hash("touch") and action.pressed then
     	if self.has_child then
     	if self.has_child then
 			msg.post("child", "set_parent", { keep_world_transform = 1 }) -- <5>
 			msg.post("child", "set_parent", { keep_world_transform = 1 }) -- <5>
 			label.set_text("#label", "Click to child...") -- <6>
 			label.set_text("#label", "Click to child...") -- <6>

+ 1 - 1
examples/basics/spawn/bunny.script

@@ -3,7 +3,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then -- <2>
+	if action_id == hash("touch") and action.pressed then -- <2>
 		local pos = go.get_position()
 		local pos = go.get_position()
 		pos.x = pos.x + 100 -- <3>
 		pos.x = pos.x + 100 -- <3>
 		local carrot_id = factory.create("#carrotfactory", pos) -- <4>
 		local carrot_id = factory.create("#carrotfactory", pos) -- <4>

+ 1 - 1
examples/debug/physics/physics.script

@@ -4,7 +4,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then
+	if action_id == hash("touch") and action.pressed then
 		msg.post("@system:", "toggle_physics_debug") -- <3>
 		msg.post("@system:", "toggle_physics_debug") -- <3>
 		if self.show_debug then -- <4>
 		if self.show_debug then -- <4>
 			msg.post("main:/loader", "set_time_step", { factor = 1, mode = 0 })
 			msg.post("main:/loader", "set_time_step", { factor = 1, mode = 0 })

+ 1 - 1
examples/debug/profile/profile.script

@@ -3,7 +3,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then
+	if action_id == hash("touch") and action.pressed then
 		msg.post("@system:", "toggle_profile") -- <2>
 		msg.post("@system:", "toggle_profile") -- <2>
 	end
 	end
 end
 end

+ 1 - 1
examples/gui/button/button.gui_script

@@ -3,7 +3,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then -- <2>
+	if action_id == hash("touch") and action.pressed then -- <2>
 		local button = gui.get_node("button") -- <3>
 		local button = gui.get_node("button") -- <3>
 		local text = gui.get_node("text") -- <4>
 		local text = gui.get_node("text") -- <4>
 		if gui.pick_node(button, action.x, action.y) then -- <5>
 		if gui.pick_node(button, action.x, action.y) then -- <5>

+ 1 - 1
examples/gui/load_texture/load_texture.gui_script

@@ -41,7 +41,7 @@ function init(self)
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") and action.pressed then
+	if action_id == hash("touch") and action.pressed then
 		if gui.pick_node(self.button, action.x, action.y) then -- <12>
 		if gui.pick_node(self.button, action.x, action.y) then -- <12>
 			start_load_random(self) -- <3>
 			start_load_random(self) -- <3>
 		end
 		end

+ 1 - 1
examples/input/down_duration/down_duration.md

@@ -1,6 +1,6 @@
 ---
 ---
 title: Down duration
 title: Down duration
-brief: Listens to input trigger "click" and count mouse down duration in update method.
+brief: Listens to input trigger "touch" and count mouse down duration in update method.
 scripts: down_duration.script
 scripts: down_duration.script
 ---
 ---
 
 

+ 2 - 2
examples/input/down_duration/down_duration.script

@@ -11,7 +11,7 @@ local function update_text(self) -- <3>
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-	if action_id == hash("click") then -- <6>
+	if action_id == hash("touch") then -- <6>
 		if action.pressed then -- <7>
 		if action.pressed then -- <7>
 			self.is_start_timer = true -- <8>
 			self.is_start_timer = true -- <8>
 		elseif action.released then -- <9>
 		elseif action.released then -- <9>
@@ -36,7 +36,7 @@ end
 3. Create method for updating the text label.
 3. Create method for updating the text label.
 4. Create a formatted string from the format and duration and last_duration arguments.
 4. Create a formatted string from the format and duration and last_duration arguments.
 5. Set the label component to the stored text.
 5. Set the label component to the stored text.
-6. Check if we receive an input action named "click".
+6. Check if we receive an input action named "touch".
 7. Check if it is pressed then run the following.
 7. Check if it is pressed then run the following.
 8. Change flag for starting a timer.
 8. Change flag for starting a timer.
 9. Check if it is released then run the following.
 9. Check if it is released then run the following.

BIN
examples/input/down_duration/input_binding.png


+ 2 - 2
examples/physics/kinematic/kinematic.script

@@ -8,7 +8,7 @@ local function landed(self) -- <9>
 end
 end
 
 
 function on_input(self, action_id, action)
 function on_input(self, action_id, action)
-    if action_id == hash("click") and action.pressed then -- <3>
+    if action_id == hash("touch") and action.pressed then -- <3>
 		if not self.moving then -- <4>
 		if not self.moving then -- <4>
 			msg.post("#label", "disable") -- <5>
 			msg.post("#label", "disable") -- <5>
 			self.moving = true -- <6>
 			self.moving = true -- <6>
@@ -21,7 +21,7 @@ end
 --[[
 --[[
 1. Tell the engine that this object ("." is shorthand for the current game object) should listen to input. Any input will be received in the `on_input()` function.
 1. Tell the engine that this object ("." is shorthand for the current game object) should listen to input. Any input will be received in the `on_input()` function.
 2. Store a flag in `self` (the current script component) to indicate if the game object is moving or not.
 2. Store a flag in `self` (the current script component) to indicate if the game object is moving or not.
-3. If we receive an input action named "click" and it is pressed then run the following.
+3. If we receive an input action named "touch" and it is pressed then run the following.
 4. If the `moving` flag is not set.
 4. If the `moving` flag is not set.
 5. Disable (don't show) the help text label.
 5. Disable (don't show) the help text label.
 6. Set the `moving` flag.
 6. Set the `moving` flag.

+ 2 - 2
input/game.input_binding

@@ -20,11 +20,11 @@ key_trigger {
 }
 }
 mouse_trigger {
 mouse_trigger {
   input: MOUSE_BUTTON_LEFT
   input: MOUSE_BUTTON_LEFT
-  action: "click"
+  action: "touch"
 }
 }
 touch_trigger {
 touch_trigger {
   input: TOUCH_MULTI
   input: TOUCH_MULTI
-  action: "touch"
+  action: "multitouch"
 }
 }
 text_trigger {
 text_trigger {
   input: TEXT
   input: TEXT