Search the Community

Showing results for tags 'signals'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 7 results

  1. Hi, I'm looking for an explanation for the following behaviour: I have a class "Main" extending Phaser.State, a class "Emitter" and a class "Receiver" extending Phaser.Sprite If I dispatch a signal from "Emitter" and listen to it in "Receiver" everything works as expected or to be more precise: "" has the object "App" assigned. If I reload the state and dispatch again the signal two things happen: The listener receives the signal two times. The 1st time "" is null, the 2nd time "" contains again the object "App" (please have a look at the screenshot showing the console output) Does anybody have an explanation for this behaviour? Thanks, Boris The code (TypeScript) export class Game extends Phaser.Game { constructor() { super(480, 640, Phaser.AUTO, 'content', null); this.state.add('Main', Main, true); console.log("Game started"); } } class Main extends Phaser.State { private emitter: Emitter; private receiver: Receiver; preload() { this.load.image('logo', 'assets/logo.png'); } create() { this.emitter = new Emitter(; this.receiver = new Receiver(; const rKey = this.input.keyboard.addKey(Phaser.Keyboard.R); rKey.onDown.add(() => { console.log('reload state Main');'Main',true,false); }, this); } } class Emitter { // -- Signals static onEventFromEmitter: Phaser.Signal = new Phaser.Signal(); constructor(private game: Phaser.Game) { const spaceKey =; spaceKey.onDown.add(() => { Emitter.onEventFromEmitter.dispatch(); }, this); } } class Receiver extends Phaser.Sprite { constructor(game: Phaser.Game) { super(game, 0, 0, 'logo');; this.subscribe(); } /** * Subscribe to events */ private subscribe(): void { Emitter.onEventFromEmitter.add(() => { console.log('Game object in Receiver, listening to onEventFromEmitter',; }, this); } }
  2. Hey guys, Phaser newbie here, need some help with events. How are people dispatching custom events throughout their games. Let's say for example you have 2 classes. Main and Car. Main adds the Car class. The Main class needs to know when the car is low on petrol to update the UI. So would you use Phaser.Signals to handle this communication, or would you just call a function in the Main class directly from the Car class? Are there plans to improve events in Phaser? I understand events can't be global to the Phaser namespace because we need to support multiple Phaser instances, but couldn't events exist globally inside each World instance? All display objects within the World could dispatch and listen for events. Events could bubble up the display list. Does this sound feasible? Thanks! Matt.
  3. Mat Groves


    Hey All! Thought you guys might like too check out mini-runner a simple alternative to events and signals with an emphasis on performance. It currently forms the backbone of the messaging system in our game engine. Its working out great for things like update events, collision events etc. Great to use if you are say looping through and array and calling the same function on each object. The resulting code is cleaner than a loop whilst still keeping the performance as fast as possible. So yeah, if you are dispatching signals/events to a lot of listeners often (like everyframe often), then I would considor using this alternative. For most cases, this performace boost is not really important enough to switch from your current fave. Think of this as a nice alternative for when speed really counts! Cheers!
  4. Hey guys, can you point me at any example usage of Phaser Signals which is a bit more in-depth than a 2-liner? Surprised me how few descriptions i found compared how powerful / important feature it is in Phaser, and how many question admittedly coming on this topic. I read the other link i found What i would be curious: 1. example how to implement publish-subscribe / observers with Signals from player's hero to enemy types & vice-versa, or 2. examples on a general architecture / best practices for broader usage on custom events in a Phaser game, any case study etc. I'm sure i'll come out my own solutions soon, but would really curious how you are using, as relying fully on events are becoming widespread in the wider webdev world, i.e. Flux, Redux Thanks!
  5. Hey Everyone, I hope someone could help me with this, or if anyone has run into this issue before. I've noticed when I add a signal to an extended sprite, it will be executed immediately. Has anyone run into this issue before? var Card = function(game, x, y, data){, game, x, y, 'cardFront'); this.cardName = data.cardName || null; // String this.scale.setTo(0.15,0.15);};Card.prototype = Object.create(Phaser.Sprite.prototype);Card.prototype.constructor = Card;var card = new Card(, 0, 0, {name:'test'});card.input.useHandCursor = true;, this, 0, 'arg1', 'arg2');HighlightCard = function(sprite, pointer, arg1, arg2){ console.log('highlight:', sprite, pointer, arg1, arg2);}; Thank you!
  6. Is it good practice to do the following: = new Phaser.Signal();; Or should the events property be left for Phaser's own events only? And if it's ok - Since I'm using Typescript, how can I get around Webstorm complaining about Unresolved variable onBloomOver - some sort of Interface?
  7. Signals are a light-weight, strongly typed messaging tool and we use them extensively in our game framework. And we’ve just released our TypeScript implementation for others to benefit from. It’s a conversion of js-signals by Miller Medeiros, which is of course in turn a conversion of AS3-Signals by Robert Penner. You can get TypeScript-Signals from github. If you are unfamiliar with Signals, how they work and how they compare to Events then this short summary is well worth a quick read, but to summarise: A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.A Signal gives an event a concrete membership in a class.Listeners subscribe to real objects, not to string-based channels.Event string constants are no longer needed.Signals are inspired by C# events and signals/slots in Qt. I ported over all of the 18 unit tests to TypeScript as well. So you have plenty of examples: from adding a basic listener up to manual binding and dynamic context switching.