Difference between revisions of "TntVirtualPad"
From GiderosMobile
(11 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
=== Description === | === Description === | ||
Adds a virtual pad to your game/app screen. | Adds a virtual pad to your game/app screen. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | require "tntvirtualpad" | ||
+ | </syntaxhighlight> | ||
You can find the graphics for the pads and the text file that comes with it: | You can find the graphics for the pads and the text file that comes with it: | ||
Line 12: | Line 15: | ||
[[file:TNTVirtualPad.png]] | [[file:TNTVirtualPad.png]] | ||
− | === | + | === Example === |
'''Add a virtual pad to your scene''' | '''Add a virtual pad to your scene''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
require "tntvirtualpad" | require "tntvirtualpad" | ||
Line 57: | Line 60: | ||
end | end | ||
end | end | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- | ||
Line 64: | Line 67: | ||
[[CTNTVirtualPad.new]] ''creates a new VPAD object class''<br/><!-- GIDEROSMTD:CTNTVirtualPad.new() creates a new TNT Virtual Pad object (Class)--> | [[CTNTVirtualPad.new]] ''creates a new VPAD object class''<br/><!-- GIDEROSMTD:CTNTVirtualPad.new() creates a new TNT Virtual Pad object (Class)--> | ||
− | [[CTNTVirtualPad:free]] ''frees the VPAD''<br/><!-- GIDEROSMTD:CTNTVirtualPad:free() frees the VPAD--> | + | [[CTNTVirtualPad:free]] ''frees the VPAD''<br/><!--GIDEROSMTD:CTNTVirtualPad:free() frees the VPAD--> |
− | [[CTNTVirtualPad:setAlpha]] ''sets VPAD alpha values''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setAlpha(alphaOn, alphaOff) max alpha value when pad is visible on screen, min alpha value when pad is in “ghost” mode--> | + | [[CTNTVirtualPad:setAlpha]] ''sets VPAD alpha values''<br/><!--GIDEROSMTD:CTNTVirtualPad:setAlpha(alphaOn, alphaOff) max alpha value when pad is visible on screen, min alpha value when pad is in “ghost” mode--> |
− | [[CTNTVirtualPad:setColor]] ''sets VPAD colors''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setColor(padComponent, r, g, b) sets the VPAD components colors--> | + | [[CTNTVirtualPad:setColor]] ''sets VPAD colors''<br/><!--GIDEROSMTD:CTNTVirtualPad:setColor(padComponent, r, g, b) sets the VPAD components colors--> |
− | [[CTNTVirtualPad:setHideDelay]] ''sets VPAD hide delay''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setHideDelay(msDelay) sets the VPAD hide delay--> | + | [[CTNTVirtualPad:setDefaultButtonSprites]] ''sets VPAD default buttons sprites''<br/><!--GIDEROSMTD:CTNTVirtualPad:setDefaultButtonSprites(spriteA, spriteB) sets the VPAD default buttons sprites !warning! SEE THE WIKI--> |
− | [[CTNTVirtualPad:setHideMode]] ''sets VPAD hide mode''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setHideMode(hideMode) sets the VPAD hide mode--> | + | [[CTNTVirtualPad:setDefaultJoySprites]] ''sets VPAD default joysticks sprites''<br/><!--GIDEROSMTD:CTNTVirtualPad:setDefaultJoySprites(spriteA, spriteB) sets the VPAD default joysticks sprites !warning! SEE THE WIKI--> |
− | [[CTNTVirtualPad:setJoyAsAnalog]] ''sets VPAD joysticks analog mode''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setJoyAsAnalog(padComponent, isAnalogic) sets the VPAD joysticks analog mode--> | + | [[CTNTVirtualPad:setHideDelay]] ''sets VPAD hide delay''<br/><!--GIDEROSMTD:CTNTVirtualPad:setHideDelay(msDelay) sets the VPAD hide delay--> |
− | [[CTNTVirtualPad:setJoyStyle]] ''sets VPAD joysticks movement style''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setJoyStyle(padComponent, style) sets the VPAD joysticks movement style--> | + | [[CTNTVirtualPad:setHideMode]] ''sets VPAD hide mode''<br/><!--GIDEROSMTD:CTNTVirtualPad:setHideMode(hideMode) sets the VPAD hide mode--> |
− | [[CTNTVirtualPad:setPosition]] ''sets VPAD joysticks positions''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setPosition(padComponent, x, y) sets the VPAD joysticks positions--> | + | [[CTNTVirtualPad:setJoyAsAnalog]] ''sets VPAD joysticks analog mode''<br/><!--GIDEROSMTD:CTNTVirtualPad:setJoyAsAnalog(padComponent, isAnalogic) sets the VPAD joysticks analog mode--> |
− | [[CTNTVirtualPad:setScale]] ''sets VPAD joysticks scale''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setScale(padComponent, scale) sets the VPAD joysticks scale--> | + | [[CTNTVirtualPad:setJoyStyle]] ''sets VPAD joysticks movement style''<br/><!--GIDEROSMTD:CTNTVirtualPad:setJoyStyle(padComponent, style) sets the VPAD joysticks movement style--> |
− | [[CTNTVirtualPad:setTextures]] ''sets VPAD components textures''<br/><!-- GIDEROSMTD:CTNTVirtualPad:setTextures(padComponent, textureA, textureB) sets the VPAD components textures--> | + | [[CTNTVirtualPad:setMaxRadius]] ''sets VPAD max touch radius''<br/><!--GIDEROSMTD:CTNTVirtualPad:setMaxRadius(padComponent, maxRadius) sets the VPAD max touch radius--> |
− | [[CTNTVirtualPad:start]] ''starts the VPAD''<br/><!-- GIDEROSMTD:CTNTVirtualPad:start() starts the VPAD--> | + | [[CTNTVirtualPad:setPosition]] ''sets VPAD joysticks positions''<br/><!--GIDEROSMTD:CTNTVirtualPad:setPosition(padComponent, x, y) sets the VPAD joysticks positions--> |
+ | [[CTNTVirtualPad:setScale]] ''sets VPAD joysticks scale''<br/><!--GIDEROSMTD:CTNTVirtualPad:setScale(padComponent, scale) sets the VPAD joysticks scale--> | ||
+ | [[CTNTVirtualPad:setTextures]] ''sets VPAD components textures''<br/><!--GIDEROSMTD:CTNTVirtualPad:setTextures(padComponent, textureA, textureB) sets the VPAD components textures--> | ||
+ | [[CTNTVirtualPad:start]] ''starts the VPAD''<br/><!--GIDEROSMTD:CTNTVirtualPad:start() starts the VPAD--> | ||
+ | [[CTNTVirtualPad:stop]] ''stops the VPAD''<br/><!--GIDEROSMTD:CTNTVirtualPad:stop() stops the VPAD and its events--> | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
+ | === Events === | ||
+ | <!--[[Event.ADDED_TO_STAGE]]<br/>--><!--GIDEROSEVT:Event.ADDED_TO_STAGE addedToStage--> | ||
+ | [[CTNTVirtualPad.Event|PAD.LEFTPAD_EVENT]] ''Event on the left pad'' <br/><!--GIDEROSEVT:PAD.LEFTPAD_EVENT Event on the left pad --> | ||
+ | [[CTNTVirtualPad.Event|PAD.RIGHTPAD_EVENT]] ''Event on the right pad'' <br/><!--GIDEROSEVT:PAD.RIGHTPAD_EVENT Event on the right pad --> | ||
+ | |||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON1_EVENT]] ''Event on the button 1'' <br/><!--GIDEROSEVT:PAD.BUTTON1_EVENT Event on the button 1--> | ||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON2_EVENT]] ''Event on the button 2'' <br/><!--GIDEROSEVT:PAD.BUTTON2_EVENT Event on the button 2--> | ||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON3_EVENT]] ''Event on the button 3'' <br/><!--GIDEROSEVT:PAD.BUTTON3_EVENT Event on the button 3--> | ||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON4_EVENT]] ''Event on the button 4'' <br/><!--GIDEROSEVT:PAD.BUTTON4_EVENT Event on the button 4--> | ||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON5_EVENT]] ''Event on the button 5'' <br/><!--GIDEROSEVT:PAD.BUTTON5_EVENT Event on the button 5--> | ||
+ | [[CTNTVirtualPad.Event|PAD.BUTTON6_EVENT]] ''Event on the button 6'' <br/><!--GIDEROSEVT:PAD.BUTTON6_EVENT Event on the button 6--> | ||
− | |||
− | |||
=== Constants === | === Constants === | ||
− | [[PAD.BUTTONS_NONE]]<br/><!-- GIDEROSCST:PAD.BUTTONS_NONE 3--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_NONE]]<br/><!--GIDEROSCST:PAD.BUTTONS_NONE 3--> |
− | [[PAD.BUTTONS_ONE]]<br/><!-- GIDEROSCST:PAD.BUTTONS_ONE 4--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_ONE]]<br/><!--GIDEROSCST:PAD.BUTTONS_ONE 4--> |
− | [[PAD.BUTTONS_TWO]]<br/><!-- GIDEROSCST:PAD.BUTTONS_TWO 5--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_TWO]]<br/><!--GIDEROSCST:PAD.BUTTONS_TWO 5--> |
− | [[PAD.BUTTONS_THREE]]<br/><!-- GIDEROSCST:PAD.BUTTONS_THREE 6--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_THREE]]<br/><!--GIDEROSCST:PAD.BUTTONS_THREE 6--> |
− | [[PAD.BUTTONS_FOUR]]<br/><!-- GIDEROSCST:PAD.BUTTONS_FOUR 7--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_FOUR]]<br/><!--GIDEROSCST:PAD.BUTTONS_FOUR 7--> |
− | [[PAD.BUTTONS_FIVE]]<br/><!-- GIDEROSCST:PAD.BUTTONS_FIVE 8--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_FIVE]]<br/><!--GIDEROSCST:PAD.BUTTONS_FIVE 8--> |
− | [[PAD.BUTTONS_SIX]]<br/><!-- GIDEROSCST:PAD.BUTTONS_SIX 9--> | + | [[CTNTVirtualPad.Constants|PAD.BUTTONS_SIX]]<br/><!--GIDEROSCST:PAD.BUTTONS_SIX 9--> |
− | [[PAD.COMPO_BUTTON1]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON1 20--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON1]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON1 20--> |
− | [[PAD.COMPO_BUTTON2]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON2 21--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON2]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON2 21--> |
− | [[PAD.COMPO_BUTTON3]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON3 22--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON3]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON3 22--> |
− | [[PAD.COMPO_BUTTON4]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON4 23--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON4]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON4 23--> |
− | [[PAD.COMPO_BUTTON5]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON5 24--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON5]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON5 24--> |
− | [[PAD.COMPO_BUTTON6]]<br/><!-- GIDEROSCST:PAD.COMPO_BUTTON6 25--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_BUTTON6]]<br/><!--GIDEROSCST:PAD.COMPO_BUTTON6 25--> |
− | [[PAD.COMPO_LEFTPAD]]<br/><!-- GIDEROSCST:PAD.COMPO_LEFTPAD 26--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_LEFTPAD]]<br/><!--GIDEROSCST:PAD.COMPO_LEFTPAD 26--> |
− | [[PAD.COMPO_RIGHTPAD]]<br/><!-- GIDEROSCST:PAD.COMPO_RIGHTPAD 27--> | + | [[CTNTVirtualPad.Constants|PAD.COMPO_RIGHTPAD]]<br/><!--GIDEROSCST:PAD.COMPO_RIGHTPAD 27--> |
− | [[PAD.MODE_NOHIDE]]<br/><!-- GIDEROSCST:PAD.MODE_NOHIDE 13--> | + | [[CTNTVirtualPad.Constants|PAD.MODE_NOHIDE]]<br/><!--GIDEROSCST:PAD.MODE_NOHIDE 13--> |
− | [[PAD.MODE_GHOST]]<br/><!-- GIDEROSCST:PAD.MODE_GHOST 14--> | + | [[CTNTVirtualPad.Constants|PAD.MODE_GHOST]]<br/><!--GIDEROSCST:PAD.MODE_GHOST 14--> |
− | [[PAD.MODE_HIDDEN]]<br/><!-- GIDEROSCST:PAD.MODE_HIDDEN 15--> | + | [[CTNTVirtualPad.Constants|PAD.MODE_HIDDEN]]<br/><!--GIDEROSCST:PAD.MODE_HIDDEN 15--> |
− | [[PAD.STICK_NONE]]<br/><!-- GIDEROSCST:PAD.STICK_NONE 0--> | + | [[CTNTVirtualPad.Constants|PAD.STICK_NONE]]<br/><!--GIDEROSCST:PAD.STICK_NONE 0--> |
− | [[PAD.STICK_SINGLE]]<br/><!-- GIDEROSCST:PAD.STICK_SINGLE 1--> | + | [[CTNTVirtualPad.Constants|PAD.STICK_SINGLE]]<br/><!--GIDEROSCST:PAD.STICK_SINGLE 1--> |
− | [[PAD.STICK_DOUBLE]]<br/><!-- GIDEROSCST:PAD.STICK_DOUBLE 2--> | + | [[CTNTVirtualPad.Constants|PAD.STICK_DOUBLE]]<br/><!--GIDEROSCST:PAD.STICK_DOUBLE 2--> |
− | [[PAD.STYLE_CLASSIC]]<br/><!-- GIDEROSCST:PAD.STYLE_CLASSIC 10--> | + | [[CTNTVirtualPad.Constants|PAD.STYLE_CLASSIC]]<br/><!--GIDEROSCST:PAD.STYLE_CLASSIC 10--> |
− | [[PAD.STYLE_MOVABLE]]<br/><!-- GIDEROSCST:PAD.STYLE_MOVABLE 11--> | + | [[CTNTVirtualPad.Constants|PAD.STYLE_MOVABLE]]<br/><!--GIDEROSCST:PAD.STYLE_MOVABLE 11--> |
− | [[PAD.STYLE_FOLLOW]]<br/><!-- GIDEROSCST:PAD.STYLE_FOLLOW 12--> | + | [[CTNTVirtualPad.Constants|PAD.STYLE_FOLLOW]]<br/><!--GIDEROSCST:PAD.STYLE_FOLLOW 12--> |
|} | |} | ||
{{GIDEROS IMPORTANT LINKS}} | {{GIDEROS IMPORTANT LINKS}} |
Latest revision as of 23:26, 12 November 2023
Supported platforms:
Available since: Gideros 2019.4
Description
Adds a virtual pad to your game/app screen.
require "tntvirtualpad"
You can find the graphics for the pads and the text file that comes with it:
Example
Add a virtual pad to your scene
require "tntvirtualpad"
LevelX = Core.class(Sprite)
function LevelX:init()
-- bg
application:setBackgroundColor(0x0099a0)
-- tnt virtual pad
local texturevpad = TexturePack.new("gfx/UI/TNTVirtualPad.txt", "gfx/UI/TNTVirtualPadX.png", true)
self.vPad = CTNTVirtualPad.new(self, texturevpad, PAD.STICK_SINGLE, PAD.BUTTONS_ONE, 100, 0)
self.vPad:setJoyStyle(PAD.COMPO_LEFTPAD, PAD.STYLE_FOLLOW)
self.vPad:setScale(PAD.COMPO_LEFTPAD, 1)
self.vPad:setScale(PAD.COMPO_BUTTON1, 1)
self.vPad:setHideDelay(5000)
self.vPad:start()
-- tnt virtual pad listeners
self.vPad:addEventListener(PAD.LEFTPAD_EVENT, self.onVKeyDown, self)
self.vPad:addEventListener(PAD.BUTTON1_EVENT, self.vShoot, self)
end
-- VIRTUAL PAD HANDLER
function LevelX:onVKeyDown(event)
print(event.data.power)
print(event.data.angle)
print(math.cos(event.data.angle))
print(math.sin(event.data.angle))
-- example usage
--self.player.posx += self.player.vx * math.cos(event.data.angle)
--self.player.posy += self.player.vy * math.sin(event.data.angle)
--if math.cos(event.data.angle) < 0 then self.player:setSkew(5, -5)
--elseif math.cos(event.data.angle) > 0 then self.player:setSkew(-5, 5)
--else self.player:setSkew(0, 0)
--end
end
function LevelX:vShoot(event)
if event.data.state == PAD.STATE_BEGIN then
-- example usage
--local missile = Missiles.new(self.player.posx, self.player.posy - 12)
--table.insert(self.missiles_list, missile)
end
end