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