本文整理匯總了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);
};
});