*   >> Leitura Educação Artigos >> science >> programação

Fazendo um clone de Space Invaders com PushButton - Explosions

(); owner.eventDispatcher.removeEventListener (HealthComponent.DIED, onDied); } Function protegido onDied (event: Event): void {var posição: Ponto = owner.getProperty (PositionReference); entidade var: IEntity = TemplateManager.instance.instantiateEntity ("Explosão"); if (entidade! = null) {var espacial: Box2DSpatialComponent = entity.lookupComponentByType (Box2DSpatialComponent) como Box2DSpatialComponent; var simpleSpatial: SimpleSpatialComponent = entity.lookupComponentByType (SimpleSpatialComponent) como SimpleSpatialComponent; if (espacial! = null) {spatial.

position = new Point (position.x, position.y); } Else if (simpleSpatial! = Null) {simpleSpatial.position = new Point (position.x, position.y); } Var Anim: AnimationController = entity.lookupComponentByType (AnimationController) como AnimationController; if (anim) anim.setAnimation (anim.animations [anim.

defaultAnimation]); }}}

Finalmente, o DestroyIfOffScreenComponent fará a contagem regressiva de um contador interno, destruindo a entidade a que pertence, uma vez que é contador chegou a zero

 classe pública estende DestroyAfterCountdownComponent TickedComponent {var TimeToLive público:. Número = 1; protegido var remainingTime: Number = 1; DestroyAfterCountdownComponent função pública () {super (); } Function protected override OnAdd (): void {super.

onAdd (); remainingTime = TimeToLive; } Function public override onTick (Tickrate: Number): void {remainingTime - = Tickrate; if (remainingTime

Page   <<  [1] [2] [3] 
Copyright © 2008 - 2016 Leitura Educação Artigos,https://artigos.nmjjxx.com All rights reserved.