Not Clicking Object


local function handle_click(url, action_id, action)
	label.set_text("/four_boxes/go#label", tostring(url))
	if action.released then
		print("Dokundu")
	end
end

function init(self)
	msg.post(".", "acquire_input_focus")
	msg.post("@render:", "clear_color", { color = vmath.vector4(95 /256, 129 / 256, 161 / 256, 1 ) })
	self.tiklandimi = false
	go.set("#sprite", "scale", vmath.vector3(1.5, 1.5, 1))
	goput.add("/four_boxes/harfler1#sprite", nil, handle_click)
	goput.add("/four_boxes/harfler2#sprite", nil, handle_click)
	goput.add("/four_boxes/harfler3#sprite", nil, handle_click)
	goput.add("/four_boxes/harfler4#sprite", nil, handle_click)
end

function on_message(self, message_id, message)
	if message_id == hash("collision_response") and self.tiklandimi == false then
		go.set(".", "scale", vmath.vector3(0.15, 0.15, 0))
		self.tiklandimi = true
	end
end

function update(self, dt)
	if message_id ~= hash("collision_response") then
		go.set(".", "scale", vmath.vector3(0.1, 0.1, 0))
		self.tiklandimi = false
	end
end

function final(self)
	msg.post(".", "release_input_focus")
	goput.remove("/four_boxes/harfler1#sprite")
	goput.remove("/four_boxes/harfler2#sprite")
	goput.remove("/four_boxes/harfler3#sprite")
	goput.remove("/four_boxes/harfler4#sprite") 
end

function on_input(self, action_id, action)
	return goput.on_input(action_id, action)
end

Dont write when i click object “Dokundu”

I’m not sure what module goput is?
Did you write it?

@Mathias_Westerdahl : I think it’s this one: https://github.com/britzl/publicexamples/blob/master/examples/click_game_object/click_game_object/goput.lua

Perhaps the input bindings are missing something? The goput module forwards input events to the callback function from what I can tell, so it seems like there’s nothing that triggers the action.released to be set.

2 Likes

Yes that is goput module, i only replace name.

I solve this problem but i want to one click by one action

local goput = require "main.goput"

local function handle_click(url, action_id, action)
	local abc
	local kontrol = false
	abc = string.sub(tostring(url), 12,31)
	abc = abc .. "#label"
	--local ciger = go.get("#label", "text")
	--print(ciger)
	label.set_text("/four_boxes/go#label", tostring(url))
	if action_id == hash("touch") and kontrol==false then
		print("Tiklandimi")
		kontrol = true
	end
	if action.released and kontrol == true then
		print("Dokundu")
		kontrol=false
	end
end

function init(self)
	msg.post(".", "acquire_input_focus")
	msg.post("@render:", "clear_color", { color = vmath.vector4(95 /256, 129 / 256, 161 / 256, 1 ) })
	self.tiklandimi = false
	go.set("#sprite", "scale", vmath.vector3(1.5, 1.5, 1))
	goput.add("#sprite", nil, handle_click)
end

function on_message(self, message_id, message)
	if message_id == hash("collision_response") and self.tiklandimi == false then
		go.set(".", "scale", vmath.vector3(0.15, 0.15, 0))
		self.tiklandimi = true
	end
end

function update(self, dt)
	if message_id ~= hash("collision_response") then
		go.set(".", "scale", vmath.vector3(0.1, 0.1, 0))
		self.tiklandimi = false
	end
end

function final(self)
	msg.post(".", "release_input_focus")
	goput.remove("#sprite")

end

function on_input(self, action_id, action)
	return goput.on_input(action_id, action)
end

It sounds like you need to filter on either action.pressed or action.released depending on what you prefer.

Check what inputs you are actually receiving, e.g. add pprint(action) in on_inputand see that is is what you expect.