New API in love-native-android
Posted: Thu Sep 06, 2012 9:30 pm
Multitouch
Called when one or more user presses on the screen.
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Called when one or more user stop touching the screen.
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Called when one or more user move over the screen.
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Sensors:
Sensors do a nice Android live cycle and disable if the screen turns off or if the user quits the application. This is to reduce power consumption.
Enable a sensor.
Parameter:
s: Name of the sensor, possible values are any sensor values from Android according to your Android version. Please use the name as string, e.g. "TYPE_ALL".
Disable a sensor.
Parameter:
s: Name of the sensor, possible values are any sensor values from Android according to your Android version. Please use the name as string, e.g. "TYPE_ALL".
Called in case of a sensor event. You need to activate sensors by calling love.sensor.activate!
Parameters:
n: Name of the sensor (String).
t: Type of the sensor (String) according to Android sensor names.
v: Values according to the sensor type. Provided as float array.
Example Touch:
Example Sensors:
Code: Select all
function love.touchpressed(x, y, i)
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Code: Select all
function love.touchreleased(x, y, i)
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Code: Select all
function love.touchmove(x, y, i)
Parameters:
x: Array/List with all x parameters
y: Array/List with all y parameters
i: Index of event that triggered the event; 0 if this feature is not supported
Sensors:
Sensors do a nice Android live cycle and disable if the screen turns off or if the user quits the application. This is to reduce power consumption.
Code: Select all
function love.sensor.enable(s)
Parameter:
s: Name of the sensor, possible values are any sensor values from Android according to your Android version. Please use the name as string, e.g. "TYPE_ALL".
Code: Select all
function love.sensor.disable(s)
Parameter:
s: Name of the sensor, possible values are any sensor values from Android according to your Android version. Please use the name as string, e.g. "TYPE_ALL".
Code: Select all
function love.sensorchanged(n,t,v)
Parameters:
n: Name of the sensor (String).
t: Type of the sensor (String) according to Android sensor names.
v: Values according to the sensor type. Provided as float array.
Example Touch:
Code: Select all
function love.touchpressed(x, y, i)
print("love.touchpressed", i)
print("x")
for index,val in pairs(x) do
print(index, "->", val)
end
print("y")
for index,val in pairs(y) do
print(index, "->", val)
end
end
function love.touchreleased(x, y, i)
print("love.touchreleased", i)
print("x")
for index,val in pairs(x) do
print(index, "->", val)
end
print("y")
for index,val in pairs(y) do
print(index, "->", val)
end
end
function love.touchmove(x, y, i)
print("love.touchmove", i)
print("x")
for index,val in pairs(x) do
print(index, "->", val)
end
print("y")
for index,val in pairs(y) do
print(index, "->", val)
end
end
Code: Select all
function love.load()
love.sensor.enable("TYPE_ALL")
end
function love.sensorchanged(n,t,v)
print(n, t)
for index, val in pairs(v) do
print(index, "->", val)
end
end