mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
basic touch system impl
This commit is contained in:
@@ -51,14 +51,36 @@
|
||||
"rigid_body" : {
|
||||
"type" : "dynamic"
|
||||
},
|
||||
"rect_collider" : {
|
||||
"size" : [66,113]
|
||||
},
|
||||
"circle_collider" : {
|
||||
"offset" : [50,25],
|
||||
"offset" : [10,15],
|
||||
"radius" : 33
|
||||
}
|
||||
}
|
||||
},
|
||||
"children" : [{
|
||||
"prototype" : "../prefabs/ship_prefab.json",
|
||||
"components" : {
|
||||
"named" : {
|
||||
"name" : "ship(11)"
|
||||
},
|
||||
"actor" : {
|
||||
"translation" : [0,0],
|
||||
"rotation" : 1,
|
||||
"scale" : [0.5,0.5]
|
||||
},
|
||||
"behaviour" : {
|
||||
"script" : "../scripts/sample_08/ship.lua"
|
||||
},
|
||||
"touchable" : {},
|
||||
"rigid_body" : {
|
||||
"type" : "dynamic"
|
||||
},
|
||||
"circle_collider" : {
|
||||
"offset" : [10,15],
|
||||
"radius" : 33
|
||||
}
|
||||
},
|
||||
"children" : []
|
||||
}]
|
||||
},{
|
||||
"prototype" : "../prefabs/ship_prefab.json",
|
||||
"components" : {
|
||||
|
||||
@@ -11,8 +11,15 @@ end
|
||||
|
||||
---@param go gobject
|
||||
---@param type string
|
||||
---@param event any
|
||||
---@param event touchable_input_evt | touchable_mouse_evt
|
||||
function M:on_event(go, type, event)
|
||||
if type == "touchable.mouse_evt" then
|
||||
the_debug:trace(string.format(
|
||||
"scene %q touched(%s %s)",
|
||||
go.named and go.named.name or "---",
|
||||
event.type,
|
||||
event.button))
|
||||
end
|
||||
end
|
||||
|
||||
---@param go gobject
|
||||
|
||||
@@ -24,4 +24,18 @@ end
|
||||
function M.on_update(meta, go)
|
||||
end
|
||||
|
||||
---@param go gobject
|
||||
---@param type string
|
||||
---@param event touchable_mouse_evt
|
||||
function M:on_event(go, type, event)
|
||||
if type == "touchable.mouse_evt" then
|
||||
the_debug:trace(string.format(
|
||||
"ship %q touched(%s %s) - %s",
|
||||
go.named and go.named.name or "---",
|
||||
event.type,
|
||||
event.button,
|
||||
go == event.target and "self" or "other"))
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user