Jump to content

Some questions about attachable objects and having a collection instead of group.


Recommended Posts



Today is the second day of using Phaser.js for me and so far I'm really liking it. Finished my first game (http://anilunal.com/games/yeni-oyun/index.html if you want to play, direction buttons to move and space for shooting)


I have some questions to ask.


1. How does a decent build process looks like? I'm thinking about using my grunt with watch the changes live and compile them into a game.min.js. Is there any better way?

2. Do you rely on ES6 features on your code? Like: (var x = arr.map(x => x*2))


3. How does the group works? Right now I have code like this:

create ->    for(var i = 0; i < 10; i++)    {         monsterCollection.push(new Monster());    }update ->    monsterCollection.each(function(monster) {        monster.update();      });monster.update ->    // Set collisions, etc. Do typical monster.update stuff.

I assume this way I am creating collision rules for very specific monster instance, where group makes every instance in the group benefit from the same collision rules?

4. Is there any easy way to decorate the map using tilesets? For example, ImpactJS had a map editor. Any such option exists here? (Searched it for a while but couldn't find anything)

5. In this game example: http://phaser.io/examples/v2/games/tanks, I don't get how turret is attached on top of the tank. (digging the source code at the moment) Do we attach sprites on top of the main sprite with X/Y positions, so each time main sprite changes his location in the world scene, sprites attached also update their position?

6. What is a good solution for the following requirement: You have a character sprite that is used for running left/right from a side view. You want him to enable three type of guns. A pistol, a minigun, and a RPG. Each of those weapon types require a different hand position to hold them. (e.g RPG can be used on top of a shoulder, while pistol is one handed) What's a proper way to get this look? Keep the main sprite same, then attach hand sprites/weapon sprites dynamically depending on which weapon is being used? (I doubt we're going to re-draw our 2D sprite, right?)


7. Is there any API docs to look at during development? (e.g like this: http://laravel.com/api/5.0/) Documentation on the website requires too many clicks and page changes.


8. Right now I spawn monsters with a setInterval(spawnMonster, 3000); on my create method. I feel like this is pretty bad approach as it would remove pause ability. The problem is, if I switch back to my Sublime Text to continue development and keep the chrome tab open, it spawns hundreds of monsters depending on how long it has been running. Is there any way to carry those logic into update method? Also, a focus checker would be great. Like, if the game screen is not focused, we could pause the game.



Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...