*   >> Lecture Éducation Articles >> science >> la programmation

Faire un clone de Space Invaders avec PushButton - Explosions

lerComponent public function () {super (); } Fonction protégée override onAdd (): void {super.onAdd (); owner.eventDispatcher.addEventListener (HealthComponent.DIED, onDied); } Protected override fonction onRemove (): void {super.onRemove (); owner.eventDispatcher.removeEventListener (HealthComponent.DIED, onDied); } Fonction protégée onDied (event: Event): void {var position: point = owner.getProperty (PositionReference); var entité: IEntity = TemplateManager.instance.instantiateEntity ("Explosion"); si (entité! = null) {var spatiale: Box2DSpatialComponent = entity.

lookupComponentByType (Box2DSpatialComponent) que Box2DSpatialComponent; var simpleSpatial: SimpleSpatialComponent = entity.lookupComponentByType (SimpleSpatialComponent) que SimpleSpatialComponent; si (spatiale! = 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) que AnimationController; si (anim) anim.setAnimation (anim.animations [anim.

defaultAnimation]); }}}

Enfin, le DestroyIfOffScreenComponent comptera à rebours d'un compteur interne, détruisant l'entité à laquelle est appartient une fois que le compteur a atteint zéro

 DestroyAfterCountdownComponent public class étend TickedComponent {TimeToLive public var:. Nombre = 1; var protégée remainingTime: Number = 1; DestroyAfterCountdownComponent public function () {super (); } Fonction protégée override onAdd (): void {super.

onAdd (); remainingTime = TimeToLive; } Public override function onTick (tickrate: Number): void {remainingTime - = tickrate; if (remainingTime

Page   <<  [1] [2] [3] 
Copyright © 2008 - 2016 Lecture Éducation Articles,https://lecture.nmjjxx.com All rights reserved.