gpt4 book ai didi

pixi.js - Pixi Js, CanvasRenderer 错误

转载 作者:行者123 更新时间:2023-12-01 10:37:53 29 4
gpt4 key购买 nike

我使用的是 pixi.js v 3.0.0我的简单代码是

(function () {
document.addEventListener('DOMContentLoaded', function () {

var width = screen.availWidth;
var height = screen.availHeight;
var renderer = PIXI.CanvasRenderer(width, height, {
backgroundColor : 0x1099bb
});

document.body.appendChild(renderer.view);
var stage = new PIXI.Container();

var texture = PIXI.Texture.fromImage('asset/bunny.png');

var bunny = new PIXI.Sprite(texture);

bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;

bunny.position.x = 200;
bunny.position.y = 150;

stage.addChild(bunny);
animate();
function animate() {
requestAnimationFrame(animate);
bunny.rotation += 0.1;
renderer.render(stage);
}
}, false);
}
());

但我得到:TypeError: this.initPlugins is not a function 如果使用 CanvasRenderer 但它在其他情况下有效

最佳答案

只需在创建 CanvasRenderer 时添加 new 关键字即可。

关于pixi.js - Pixi Js, CanvasRenderer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32608662/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com