按照教程写了Game Over的代码,但是怎么调试都无法把页面渲染出来
game over 的代码:
export default class GameOverPage {
constructor (callbacks) {
this.callbacks = callbacks
}
init (options) {
this.initGameoverCanvas(options)
}
initGameoverCanvas (options) {
const aspect = window.innerHeight / window.innerWidth
this.scene = options.scene
this.canvas = document.createElement('canvas')
this.canvas.width = window.innerWidth
this.canvas.height = window.innerHeight
this.texture = new THREE.Texture(this.canvas)
this.material = new THREE.MeshBasicMaterial({
map: this.texture,
transparent: true,
side: THREE.DoubleSide
})
this.geometry = new THREE.PlaneGeometry(window.innerWidth, window.innerHeight)
this.obj = new THREE.Mesh(this.geometry, this.material)
this.obj.position.z = 1
this.context = this.canvas.getContext('2d')
this.context.fillStyle = '#333'
this.context.fillRect((window.innerWidth - 200) / 2, (window.innerHeight - 100) / 2, 200, 100)
this.texture.needUpdate = true
this.context.fillStyle = '#eee'
this.context.font = '20px Georgia'
this.context.fillText('Game Over', (window.innerWidth - 200) /2 + 50, (window.innerHeight - 100)/2+ 55)
this.scene.add(this.obj)
console.log(this.obj)
console.log('game over page show')
}
show () {
console.log('game over page show')
}
}
程序也没有错误的提示!
登录后可查看更多问答,登录/注册
1.5k 16
1.0k 11
1.1k 11
4.8k 10
2.3k 9