app.loader.add('bunny', logo).load((loader, resources) => { // This creates a texture from a 'bunny.png' image. const bunny = newSprite(resources.bunny.texture)
// Setup the position of the bunny bunny.x = app.renderer.width / 2 bunny.y = app.renderer.height / 2
// Rotate around the center bunny.anchor.x = 0.5 bunny.anchor.y = 0.5
// Add the bunny to the scene we are building. app.stage.addChild(bunny) })
让图片运动起来
1 2 3 4 5 6 7 8 9 10
// Listen for frame updates app.ticker.add(() => { // each frame we spin the bunny around a bit // console.log('bunny.anchor.x', bunny.anchor) if (bunny.x >= app.renderer.width) { bunny.x = 0 } else { bunny.x += 1 } })