本文整理汇总了TypeScript中pixi-particles.Emitter类的典型用法代码示例。如果您正苦于以下问题:TypeScript Emitter类的具体用法?TypeScript Emitter怎么用?TypeScript Emitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Emitter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
loader.load(function()
{
debugger;
bg = new pixi.Sprite(pixi.Texture.from("../../docs/examples/images/bg.png"));
//bg is a 1px by 1px image
bg.scale.x = canvas.width;
bg.scale.y = canvas.height;
bg.tint = 0x000000;
stage.addChild(bg);
//collect the textures, now that they are all loaded
const art = [];
for(let i = 0; i < imagePaths.length; ++i)
art.push(pixi.Texture.from(imagePaths[i]));
// Create the new emitter and attach it to the stage
const emitterContainer = new pixi.Container();
stage.addChild(emitterContainer);
(window as any).emitter = emitter = new particles.Emitter(
emitterContainer,
art,
config
);
// Center on the stage
emitter.updateOwnerPos(window.innerWidth / 2, window.innerHeight / 2);
// Click on the canvas to trigger
canvas.addEventListener('mouseup', function(e){
if(!emitter) return;
emitter.emit = true;
emitter.resetPositionTracking();
emitter.updateOwnerPos(e.offsetX || e.layerX, e.offsetY || e.layerY);
});
// Start the update
update();
//for testing and debugging
(window as any).destroyEmitter = function()
{
emitter.destroy();
emitter = null;
(window as any).destroyEmitter = null;
//cancelAnimationFrame(updateId);
// V4 code - dunno what it would be in V5, or if it is needed
//reset SpriteRenderer's batching to fully release particles for GC
// if (renderer.plugins && renderer.plugins.sprite && renderer.plugins.sprite.sprites)
// renderer.plugins.sprite.sprites.length = 0;
renderer.render(stage);
};
});