当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pixi-particles.Emitter类代码示例

本文整理汇总了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);
	};
});
开发者ID:pixijs,项目名称:pixi-particles,代码行数:52,代码来源:renderer.ts


注:本文中的pixi-particles.Emitter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。