Wax: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Supported platforms:''' File:Platform ios.png<br/> '''Available since:''' Gideros 2025.9<br/> === Description === Wax is a framework that lets you write nati..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
=== Description ===
=== Description ===
Wax is a framework that lets you write native iPhone apps in Lua. It bridges Objective-C and Lua using the Objective-C runtime. With Wax, anything you can do in Objective-C is automatically available in Lua! What are you waiting for, give it a shot!
Wax is a framework that lets you write native iPhone apps in Lua. It bridges Objective-C and Lua using the Objective-C runtime. With Wax, anything you can do in Objective-C is automatically available in Lua! What are you waiting for, give it a shot!
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
require "tntvirtualpad"
require "wax"
require "wax.init"
</syntaxhighlight>
</syntaxhighlight>


=== Example ===
'''Gideros Plugin for Wax''':
'''Add a virtual pad to your scene'''
*'''https://github.com/troysandal/BhWax'''
<syntaxhighlight lang="lua">
require "tntvirtualpad"


LevelX = Core.class(Sprite)
For more information please see:
*'''https://github.com/troysandal/BhGideros'''


function LevelX:init()
=== Examples ===
-- bg
*'''https://github.com/troysandal/BhWax/tree/master/Demo'''
application:setBackgroundColor(0x0099a0)
*'''https://github.com/alibaba/wax/tree/master/examples'''
-- 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
</syntaxhighlight>


{|-
{|-

Latest revision as of 01:40, 5 September 2025

Supported platforms:
Available since: Gideros 2025.9

Description

Wax is a framework that lets you write native iPhone apps in Lua. It bridges Objective-C and Lua using the Objective-C runtime. With Wax, anything you can do in Objective-C is automatically available in Lua! What are you waiting for, give it a shot!

require "wax"
require "wax.init"

Gideros Plugin for Wax:

For more information please see:

Examples

Methods

Events

Constants