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


TypeScript js.Container.addChildAt方法代码示例

本文整理汇总了TypeScript中pixi.js.Container.addChildAt方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.Container.addChildAt方法的具体用法?TypeScript js.Container.addChildAt怎么用?TypeScript js.Container.addChildAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pixi.js.Container的用法示例。


在下文中一共展示了js.Container.addChildAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: update


//.........这里部分代码省略.........
						}
						p.speedList.reset(this.startSpeed);
						p.acceleration.x = this.acceleration.x;
						p.acceleration.y = this.acceleration.y;
						p.maxSpeed = this.maxSpeed;
						if(this.minimumScaleMultiplier != 1)
						{
							p.scaleMultiplier = Math.random() * (1 - this.minimumScaleMultiplier) + this.minimumScaleMultiplier;
						}
						p.scaleList.reset(this.startScale);
						p.colorList.reset(this.startColor);
						//randomize the rotation speed
						if(this.minRotationSpeed == this.maxRotationSpeed)
							p.rotationSpeed = this.minRotationSpeed;
						else
							p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed;
						p.rotationAcceleration = this.rotationAcceleration;
						p.noRotation = this.noRotation;
						//set up the lifetime
						p.maxLife = lifetime;
						//set the blend mode
						p.blendMode = this.particleBlendMode;
						//set the custom ease, if any
						p.ease = this.customEase;
						//set the extra data, if any
						p.extraData = this.extraData;
						//call the proper function to handle rotation and position of particle
						this._spawnFunc(p, emitPosX, emitPosY, i);
						//initialize particle
						p.init();
						//update the particle by the time passed, so the particles are spread out properly
						p.update(-this._spawnTimer);//we want a positive delta, because a negative delta messes things up
						//add the particle to the display list
						if(!p.parent)
						{
							if (this.addAtBack)
								this._parent.addChildAt(p, 0);
							else
								this._parent.addChild(p);
						}
						else
						{
							//kind of hacky, but performance friendly
							//shuffle children to correct place
							let children = this._parent.children;
							//avoid using splice if possible
							if(children[0] == p)
								children.shift();
							else if(children[children.length-1] == p)
								children.pop();
							else
							{
								let index = children.indexOf(p);
								children.splice(index, 1);
							}
							if(this.addAtBack)
								children.unshift(p);
							else
								children.push(p);
						}
						//add particle to list of active particles
						if(this._activeParticlesLast)
						{
							this._activeParticlesLast.next = p;
							p.prev = this._activeParticlesLast;
							this._activeParticlesLast = p;
						}
						else
						{
							this._activeParticlesLast = this._activeParticlesFirst = p;
						}
						++this.particleCount;
					}
				}
				//increase timer and continue on to any other particles that need to be created
				this._spawnTimer += this._frequency;
			}
		}
		//if the position changed before this update, then keep track of that
		if(this._posChanged)
		{
			this._prevEmitterPos.x = curX;
			this._prevEmitterPos.y = curY;
			this._prevPosIsValid = true;
			this._posChanged = false;
		}

		//if we are all done and should destroy ourselves, take care of that
		if (!this._emit && !this._activeParticlesFirst)
		{
			if (this._completeCallback)
			{
				this._completeCallback();
			}
			if (this._destroyWhenComplete)
			{
				this.destroy();
			}
		}
	}
开发者ID:pixijs,项目名称:pixi-particles,代码行数:101,代码来源:Emitter.ts


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