import { utils, Application, Graphics } from 'pixi.js'
import { PixiConfig } from './constants'
const kind = utils.isWebGLSupported() ? 'WebGL' : 'canvas'
utils.sayHello(kind)
const state = {
circle: { x: 0, y: 0}
}
const stage = () => {
const graphics = new Graphics()
graphics.lineStyle(0)
graphics.beginFill(0xFFFF0B, .5)
graphics.drawCircle(state.circle.x,90,60)
graphics.endFill()
return graphics
}
const gameLoop = delta => {
state.circle.x += 1 + delta
}
const setup = () => {
const app = new Application(PixiConfig)
document.body.appendChild(app.view)
app.stage.addChild(stage())
app.ticker.add(delta => gameLoop(delta))
}
setup()
Hi,
I recently started to learn PIXI and now Im playing with animations using the ticker.
This code actually draws a circle and I can se gameLoop() is being called and updating state.circle.x though it looks like it not redrawing the stage.
What Im missing?