• Content count

  • Joined

  • Last visited

  1. Yeah, I was very keen NOT to eject the project because it makes things a lot more complicated. I did manage to get it working via that route by making some changes to the webpack config file that gets generated when you eject the project. However, it wasn't much fun working with the project once ejected. I ended up NOT ejecting the project but just including the phaser JavaScript file in the "scripts" section of .angular-cli.json. Then in the component where I use phaser I added: declare var Phaser: any; I think that was everything I did. It works a treat and means I can easily update the phaser JavaScript file by just replacing it rather than using npm as Rich iterates the updates and fixes bugs etc. I hope that helps and let me know if I missed anything.
  2. Hi @LordLants - I did get it working, but I took a rather unconventional route to do it in the end. I'm using game classes so that I can keep the games modular. I pass the context into the class constructor and then set a local variable to store that context. The following is cut down, but gives the idea: export class GAME_SpaceShooter extends (Phaser.Scene as { new(config): any; }) { constructor ( config, context ) { super(config); this.context = context; } sendGameEvent(gameEvent: string) : void {; } } I then have an interface as follows based on this article: import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import {Broadcaster} from './broadcastEvent'; @Injectable() export class GameEvent { constructor(private broadcaster: Broadcaster) {} fire(data: string): void { this.broadcaster.broadcast(MessageEvent, data); } on(): Observable<string> { return this.broadcaster.on<string>(MessageEvent); } } I import the interface into my main page class and subscribe to the gameEvent: ... import { GameEvent } from '../../interfaces/gameEvent'; @Component({ selector: 'app-game', templateUrl: './game.component.html', styleUrls: ['./game.component.css'] }) export class GameComponent implements OnInit { constructor( public gameEvent: GameEvent ) { } getGameStartDataProcessed(response: any, allOk: Boolean): void {//this is called after the XHR returns some app specific data from the server this.gameEventSubscribe = this.gameEvent.on().subscribe(eventName => { switch (eventName) { case 'eventId1': //do stuff break; case 'eventId2': //do other stuff break; default: break; } }); } } This works fine for me. I think I got everything in the description above, but let me know if you have any problems. Good luck!
  3. Adding tween targets to existing tween

    Thanks, that's great to know and much appreciated.
  4. Adding tween targets to existing tween

    Thanks. This is more the kind of thing I was after, much appreciated. However, it seems be replacing the current target with the new one and then restarting rather than adding new targets to the existing tween. I assume that you can't just push to the targets array without restarting?
  5. Adding tween targets to existing tween

    Thanks both. @samme that's a nice example. Is there a way to actually add tween targets on the fly though? So create the tween and then add tween targets to that tween as the game progresses?
  6. Collision detection

    Apols - just found this
  7. Collision detection

    Hi all What's the easiest way to just detect that two objects have touched one another please? I've tried colliders, but when the objects hit each other they actually impact and I can't see any settings to prevent that. My character is just collecting stars, and so I don't want the character to bounce off the star when it hits it. Thanks!
  8. Learn: Phaser 2 or Phaser 3?

    Phaser 3. It's great and although it's still very new it's really easy to use and works brilliantly.
  9. Hi All I'm writing a basic platformer which has prizes that I'd like to be undulating in scale. The prizes are generated dynamically as the game progresses. I am using the following tween for this, newly assigning the tween to each new prize as it is created: this.tweens.add({ targets: [scObjCreated], scaleX: '-=.2', scaleY: '-=.2', duration: 700, ease: 'Sine.easeInOut', repeat: -1, yoyo: true }); However, this seems inefficient as I know that you can have one tween with multiple targets, so having loads of tweens that all do the same thing seems like poor practice. I tried assigning the tween to a variable as follows: this.MyTween = this.tweens.add({ targets: [scObjCreated], scaleX: '-=.2', scaleY: '-=.2', duration: 700, ease: 'Sine.easeInOut', repeat: -1, yoyo: true }); ...and then pushing the newly created prize objects to the "targets" array as follows: this.MyTween.targets.push(myNewObject); However, this doesn't seem to do anything. Is there a way to do this please? Thank you!
  10. Hi all I am using Angular 4 and creating an interface which has a number of games. They load in a modal (i.e. no page refresh/change) and I then destroy them with this.phaserGame.destroy(true); I have background audio that I am playing with the following: preload () : void {'bg', [ this.p('audio/bg.mp3'), this.p('audio/bg.ogg') ]); } this.p() just gets the relative path. create () : void { this.sound_bg = this.sound.add('bg', { loop: true }); } When I destroy and reload the game, the background audio object seems to still be in the DOM and plays over itself on second game launch. I've had a look through the documentation and tried removeByKey() remove() and destroy() in the BaseSoundManager() namespace just before destroying the game. None of these seem to solve the problem though. What is best practice for completely destroying sounds please? Thank you!
  11. Should I use Phaser 3?

    I've been using Phaser 3 for a few weeks now (having never used Phaser 2). It's super easy to use, there is enough documentation to get started, and it isn't buggy. I'm even teaching it to my 7 and 9 year olds at the moment. They understand it (mostly). So I would say, go for Phaser 3. It's verrrry nice.
  12. Documentation

    Thank you. It is a fantastic engine. Once you get the hang of the way groups work it's just sooooo easy to work with. Great job!
  13. Particles

    LOL, I'm a dimwit. I was looking for a namespace rather than in Game Objects. Apologies and thank you!
  14. Particles

    Hi All Do we know if there is any support for particle systems at this point please? I can't find any reference to it in the Phaser docs and I believe that Pixi has been dropped in this version (I never used Phaser 2, but I think that was the particle engine in that). Thanks!
  15. Parent child GameObjects best practice

    Thanks @Nodragem Please see as there is discussion on this issue there, and also a Ziao has also posted a solution.