For Android, the texture is automatically added to the APK when this
module is imported. However, due to a limitation of the app.nit
framework on desktop OS, the texture must be copied manually to the assets
folder at assets/images
, the texture is available at, from the repo root,
lib/gamnit/virtual_gamepad/assets/images
.
The texture was created by kenney.nl and modified by Alexis Laferrière. It is published under CC0 and can be used and modified without attribution.
redef class App
redef fun create_scene
do
super
# Create the virtual gamepad
var gamepad = new VirtualGamepad
# Configure it as needed
gamepad.add_dpad(["w","a","s","d"])
gamepad.add_button("x", gamepad_spritesheet.x)
gamepad.add_button("space", gamepad_spritesheet.star)
# Assign it as the active gamepad
self.gamepad = gamepad
end
fun setup_play_ui
do
# Show the virtual gamepad
var gamepad = self.gamepad
if gamepad != null then gamepad.visible = true
end
end
gamnit > virtual_gamepad > art