主页 > canvas引擎 > Phaser游戏引擎 >
来源:未知 时间:2021-06-24 00:14 作者:小飞侠 阅读:次
[导读] 今天学习phaser3如何添加光源 源码解读: this.lights.enable(); this.lights.setAmbientColor(0x808080); var spotlight = this.lights.addLight(100, 100, 180).setIntensity(6); setIntensity(6) 实列: var config = { type: Phaser.WE...
今天学习phaser3如何添加光源 源码解读:
实列:var config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, scene: { preload: preload, create: create, update: update } }; var game = new Phaser.Game(config); var tilesprite; function preload () { this.load.image('brick', ['assets/normal-maps/brick.jpg', 'assets/normal-maps/brick_n.png']); } function create () { tilesprite = this.add.tileSprite(400, 300, 800, 600, 'brick').setPipeline('Light2D'); this.lights.enable(); this.lights.setAmbientColor(0x808080); var spotlight = this.lights.addLight(100, 100, 180).setIntensity(6); this.input.on('pointermove', function (pointer) { spotlight.x = pointer.x; spotlight.y = pointer.y; }); var i = 0; this.input.on('pointerdown', (pointer) => { if (i === 1) { //this.lights.enable(); this.lights.active = true; i = 0; } else { //this.lights.disable(); this.lights.active = false; i = 1; } }); } function update () { tilesprite.tilePositionX += 0.3; tilesprite.tilePositionY += 0.6; } 以上就是phaser3光源设置,感谢支持 zixuephp.com |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com