pixelhijack

Members
  • Content count

    17
  • Joined

  • Last visited

About pixelhijack

  • Rank
    Member

Contact Methods

  • Website URL
    http://pixelhijack.github.io/

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ok i made codepens to illustrate these and why i think there is a bug or bugs, check the console for each pen: 1. Previously: Phaser 2.6.2 Starting States with data: Expected behaviour: Start Boot State with initial data Initial data is passed to State init (used as dependency injection for level / game JSON) Start Game State with some other set of data State methods are in order: Boot:init, Boot:preload, Boot.create, Boot:update, Game:init, Game:preload, Game:create, Game:update Only active State is the last one started: Game Phaser 3.2.0 Starting Scenes with data - manually Expected behaviour: the same as in Phaser 2.x Actual behaviour: Boot is initialized with the default empty object, i cannot pass in initial data Game scene is not started if i start it manually from Boot:create Phaser 3.2.0 Starting Scenes with data - from config Expected behaviour: if you set active:false, or set delete key, it will be good Actual behaviour: Boot scene is only getting the default data object, cannot be passed init object However, you can pass data to Game scene (why just here?) does not matter if you set active:false, or remove it, or you do not set the key @samme
  2. @Stathis I already raised an issue for that, feel free to add anything new there, i'm looking into the SceneManager too to figure it out. https://github.com/photonstorm/phaser/issues/3363 Would be nice to have a clear view what is the flow in Phaser 3, Phaser 2 was kinda straightforward for me. To follow some architecture pattern for a game these intents would be good to know well.
  3. If i dont set it active: true, or explicitly set active: false, even both Scene, i get the very same result. Can you share a working config with my previously provided snippets where: Scenes are initialized by their keys, and not "default" Not all scenes initialized active Data is passed to any Scene, even the first? ...because this was possible in Phaser 2.x, where States were consecutive phases of a game, able to pass data. If Phaser 3 is giving the possibility to run parallelly as a plus, it is cool, but if it is not backward compatible, that is not really. Do you think i can achieve these with Phaser 3 too?
  4. Maybe my understanding on Phaser 3 Scenes are not right, but i dont really think this should be the expected behaviour based on Phaser 2.x States. What I would expect, how it worked in Phaser 2 States, that i created a State for every phase of my game: Boot loading, Menu for selecting game modes for example, Game state for the actual game which could mean switching between levels etc, and I could pass any data to any State. Now in Phaser 3 as I see following the docs, and as you describe @PixelPicoSean seems like I cannot pass data, just to the second Scene? And also when starting one Scene from a first (the "Game" from "Boot") .create() it seems like both their update() methods are being called by turns - this was also not the case with Phaser 2.x States. Can someone approve that this is an expected behaviour (and correct my misunderstanding or point to documentation where it is described) OR if it is a bug?
  5. In Phaser 2 I always used this for dependency injection, i passed all the level configs (big JSON containing asset paths, animation frames, creature props, etc, a declarative approach) to the level which was handled by State. Now i want to have the same architecture with Scene.
  6. Still, if i set either one active: false, or both, or delete the active property at all, i got the very same result, my data not passed in, i got the default empty object only. In Phaser 3.2.0. SceneManager.js:947 while debugging i see this, with the previous settings detailed previously, (which is from the docs) the entry.key is "default" while the key is "boot" which evaluates to false, so the entry.data will never set to what i'm trying to pass. for (var i = 0; i < this._pending.length; i++) { var entry = this._pending[i]; if (entry.key === key) { entry.autoStart = true; entry.data = data; } } @rich what is the expected behaviour here? Can this be also related to https://github.com/photonstorm/phaser/issues/3185 ? thanks for the help guys! Phaser rulez!!
  7. @samme @PixelPicoSean It is not working for me: i got an empty object as passed in data to my Scenes if i follow the documentation (https://phaser.io/phaser3/api/scene-manager), even with Phaser 3.1.2 and 3.2.0 too: const bootScene = { key: 'boot', active: true, init: (config) => { console.log('[BOOT] init', config); }, preload: () => { console.log('[BOOT] preload'); }, create: (config) => { console.log('[BOOT] create', config); }, update: () => { console.log('[BOOT] update'); } }; const gameScene = { key: 'game', active: true, renderToTexture: true, x: 64, y: 64, width: 320, height: 200, init: (config) => { console.log('[GAME] init', config); }, preload: () => { console.log('[GAME] preload'); }, create: (config) => { console.log('[GAME] create', config); }, update: () => { console.log('[GAME] update'); } }; const gameConfig = { type: Phaser.CANVAS, parent: 'phaser-example', width: 800, height: 600, scene: [ bootScene, gameScene ] }; const game = new Phaser.Game(gameConfig); game.scene.start('boot', { someData: '...arbitrary data' }); By stepping into the game.scene.start() method call in Phaser 3, as i see what is happening here is first the scenes are getting a "default" key, which only later gets overriden with the given key (here "boot" and "game"), but the default data remain the fallback empty object: start: function (key, data) { if (data === undefined) { data = {}; } // if not booted, then put scene into a holding pattern if (!this.game.isBooted) { for (var i = 0; i < this._pending.length; i++) { var entry = this._pending[i]; if (entry.key === key) { entry.autoStart = true; entry.data = data; } } return this; } var scene = this.getScene(key); Can this be a bug...?
  8. Does anyone know how to pass data into the game scene in Phaser 3 as you could do in Phaser 2 when started a state? game.state.start('Game', true, true, { data: 'this is some initial config' }); Phaser 3 Scene was Phaser 2 State, which you could provide parameters, the 2-3rd was as i remember caching, the 4th could be and data, which became available in the State's init() {} method as init({data}). In Phaser 3 a Scene has a second, data param, but it is not clear how it is used, the init method is not getting it, and the documentation is not ready for that as far as i know.
  9. pixelhijack

    Should I use Phaser 3?

    @Kevin84 Phaser 3 is so hot, it has just been out recently, it is a result of months of hard work, documentation is on the way, but you need to be patient, or contribute with examples Yes, I would advice to start to use Phaser 2 until then, which has a very good documentation, and once you will comfortable using Phaser 2 you will find there are a lot of overlapping with Phaser 3 i guess.
  10. ok, this is my quick attempt, a very basic, minimalistic, no-config boilerplate forked from the widely used full example project of @nkholski, merged with the minimalist template of @rich (which didn't included ES6 babel transpilation): https://github.com/pixelhijack/phaser3-es6-webpack. If @Ppozniak you are ahead with a clean one, ignore this, if you can use, let me know. We would better end up with only one, official, then yet another
  11. @Ppozniak 1. Absolutely agree, great initiation! I was redirected to this topic after trying to use my own previous boilerplate with Phaser 3 not aware new webpack config needs the raw-loader and lost in the non-official boilerplates. 2. Would tend towards creating a new one, or quickly chosing the best so far and extend that. Create-react-app is a perfect example: what happened there is everyone started to create their own boilerplate / starter kit because of js scaffolding is a nightmare, but having many starter kits is also not too optimal. 2.1. create-phaser-app? would hold the reference to make the purpose clear 2.2. clean start 3. This is the sensitive point. Usually when i want to generate a new react app / phaser game / etc, i need ONE of the following: - the most minimalistic setup i can imagine: webpack + es6 + phaser, most lightweight, npm install and ready to go in 2 mins, to bundled / deployed as quick example - full-featured, configurable, linter CI etc included, production-targeted boilerplate (like create-react-app) with everything included, preferrably configurable (this is a problem with CRA also, you can easily reach the limits without ejecting) - lightweight client-side setup WITH some minimal server (node.js) setup also (for immediate deployment to heroku / ...)
  12. pixelhijack

    Phaser Signal usage & examples

    Thanks guys! Mattstyles, you are right, it is really just another pub/sub. What i was confused is just the naming differences (especially the .add() subscribe method), but as i dig deeper for now all clear. I used Tom Atom your tutorial and found an other one too (http://www.emanueleferonato.com/2016/03/16/understanding-signal-dispatch-with-phaser/), then came up with my own decorators with a slightly different signatures, works like a charm. Later maybe i will write my lessons learnt on Phaser Signals
  13. pixelhijack

    Phaser Signal usage & examples

    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!
  14. pixelhijack

    Adding class instances to a group.

    thanks drhayes, i wasn't aware of the 'playerKey' param
  15. pixelhijack

    Adding class instances to a group.

    I have the very same question and couldn't find an answer so far: group.createMultiple(20, 'spriteImageReference') adds 20 sprites by specifying the sprite key, but how to addMultiple or createMultiple custom Phaser.Sprite instances? Let's say i created var spider = new Spider(game, 100, 50); and I want to add twenty of this spider, can i do it with addMultiple or createMultiple, without manually iterating for loops? The classType description suggests this, but it is very vague and I haven't found any example in the group examples.