我需要画布的当前渲染图像。 我在PIXI.js中需要哪种方法?
请参见最后一个函数“ addRender()”
注意: “ HTMLCanvasElement,CanvasRenderingContext2D或DataURI格式的字符串”
let Application = PIXI.Application,
Container = PIXI.Container,
loader = PIXI.loader,
resources = PIXI.loader.resources,
TextureCache = PIXI.utils.TextureCache,
Texture = PIXI.BaseTexture,
Sprite = PIXI.Sprite;
//Create a Pixi Application
let app = new Application({
width: 256,
height: 256,
antialiasing: true,
transparent: false,
resolution: 1
}
);
$('#canvas').html(app.view);
loader.add("images/cat.png").load(setup);
loader.onComplete.add(() => {});
//Define any variables that are used in more than one function
let cat;
function setup() {
cat = new Sprite(resources["images/cat.png"].texture);
cat.y = 96;
app.stage.addChild(cat);
app.ticker.add(delta => gameLoop(delta));
}
function gameLoop(delta){
cat.x += 1;
cat.y += 1;
addRender( cat)
}