Untitled

 avatar
unknown
lua
4 months ago
1.1 kB
7
No Index
<html><head>
<title>PIXI Getting Started (in Lua with fengari)</title>
<script src="https://pixijs.download/release/pixi.js"></script>
<script src="fengari_web.js" type="text/javascript" async></script>

<script type="application/lua">
local js=require('js')
local window=js.global
local document=window.document

app=js.new(window.PIXI.Application)
background=js.new(window.Object)
background.width=640
background.height=480

init_promise=app:init(background)
init_promise["then"](init_promise, function() document.body:appendChild(app.canvas)  end)  --override lua's own then command

asset_promise=window.PIXI.Assets:load('sample.png')
asset_promise["then"](asset_promise, function() sprite=window.PIXI.Sprite:from('sample.png') app.stage:addChild(sprite) sprite.x=320  sprite.y=240 sprite.pivot.x=320  sprite.pivot.y=240 zoom() end)  --override lua's own then command

scale=1

function zoom()
app.ticker:add( function(_,ticker)
                if scale>2 then return end
                scale=scale+ticker.deltaTime*0.0003
                sprite.scale:set(scale,scale)
                end
                )
end

</script>
</html>
Leave a Comment