Forum


Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Is it possible to make vPad joystick react only on move event, but not on touch event?
romka
Newbie
Posts: 2
Permalink
Post Re: Is it possible to make vPad joystick react only on move event, but not on touch event?
on: September 7, 2013, 13:11
Quote

It seems as I found a solution.

I found out that on "touch" event method leftJoy recieves next arguments:

e.data.power = 0 -- always zero
e.data.state = 17 -- always 17
e.data.selected = true
e.data.angle = <some integer value>

Arguments on "move" event:

e.data.power = <some value more then zero and less then 1>
e.data.state = 18 -- always 18
e.data.selected = true
e.data.angle = <some integer value>

Knowing this I've created to global variables in my main.lua:

power_on_touch = -1
remember_next_power = false

and I've written next code in method leftJoy:

if e.data.selected == true and e.data.state == 17 then
	remember_next_power = true
end
	
if e.data.state ~= 17 and remember_next_power == true then
	power_on_touch = e.data.power
	remember_next_power = false
end

local power_diff = 1
if e.data.state ~= 17 and e.data.power >= power_on_touch then
	power_diff = e.data.power - power_on_touch
else
	power_diff = power_on_touch - e.data.power 
end

if ticks_from_last_movement > min_ticks_for_move and e.data.power ~= 0 and power_diff > 0.1 then
	// here my code, which reacting on user input
end

In this code I remember the value of e.data.power at the moment when user touched the screen (in variable power_on_touch). Then I run my code only if current value of e.data.power is not the same as a value power_on_touch.

Now I have some more questions. Is it good solution? Is it possible, that this magic constants as e.data.state = 17 (18) will be changed in future?

romka
Newbie
Posts: 2
Permalink
Post Re: Is it possible to make vPad joystick react only on move event, but not on touch event?
on: September 7, 2013, 13:26
Quote

Oh... and I've replaced value 17 with constant PAD.STATE_BEGIN.

Pages: [1]


Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.009 seconds.