Pick_node & scaling & on_input (SOLVED)

How to pick a gui node when node is scaled down?

The below code doesn’t work properly. Works when I touch “start/frame” at centre only. No reaction when I touch at the edge of “start/frame”. Should I scale action.x and action.y?

function on_input(self, action_id, action)
    if action_id == hash("touch") and action.pressed then
    	local play_button = gui.get_node("start/frame")
     	if gui.pick_node(play_button, action.x, action.y) then
      		gui.set_scale(play_button,vmath.vector3(1.1,1.1,1))
      	end
    end
end

p.s.: I have big assets (2048x1536) only. In my game I scale down assets for lower (iPhone 5S) and scale up for larger (Samsung 6) resolutions.

gui.pick_node() takes into account the scale. I’m surprised it doesn’t work… I’ll test this myself.

I can confirm that it is indeed working:

1 Like

Are you using layout feature in your example?

No, should I do that?

Thanks!
I’ve found mistake in my GUI. My button node contains a few child nodes (frame + background + icon + text). The parent node “frame” has size 100x100, but child nodes have size 720x160.In my code I pick “start/frame”, as result the touch works at centre (100x100) of my button.

I’ve changed “frame” size to 720x160 and touches work perfectly!

2 Likes