• Content count

  • Joined

  • Last visited

  1. The easiest way is to store the name seperately in a new attribute of the object: people = game.add.group();...npc46 = people.create(1500, 880, 'npc2');npc46.myName="npc46";...people.forEach(function(character) { character.scale.setTo(0.5, 0.5); character.inputEnabled = true; character.events.onInputDown.add(function () { Dialogue(character); }, this);}, this);...function Dialogue(character){ speechbubble = game.add.sprite(character.x, character.y - 170, 'speechbubble'); speech = game.add.text(character.x + 20, character.y - 150, "Hi, I'm " + character.myName, { boundsAlignH: "left", fontSize: '12px', fill: 'black' });}Other things might get quite ugly: http://stackoverflow.com/questions/417645/how-to-convert-variable-name-to-string-in-javascript
  2. "this" in Javascript is actually the "scope" or "owner" of the function. function log_test() { console.log(this.a); }var oneObject = { a: "ownedByFirstObject", log_it: log_test};var anotherObject ={ a: "ownedByOtherObject", log_it: log_test};oneObject.log_it(); // returns "ownedByFirstObject"anotherObject.log_it(); // returns "ownedByOtherObject"Long story short: Using "this" (especially in a protoype) gives the option to apply the same code to a different object (And, yeah, javascript's "this" might be very strange for someone coming from a class-oriented language). Another usecase might be to rename the parent object without having to rewrite the code. In the Phaser example, rename "var game = ..." into "var game2 = ..." and you'd have to rewrite "game.load..." into "game2.load..." and "game.add" into "game2.add..." and so on. Using "this.game" instead, would have prevented that (Mostly because phaser adds "this.game" to every game state ( which in this case is the unnamed object "{ preload: preload, create: create, update: update, render: render }")).
  3. I'm just a causal programmer, but I support Phaser on Patreon because I think it's an really awesome library. 1. I don't know how intricate this would be, but how about a comment-option (say something like "Questions/Suggestions about this Example") that tie into the Boards(perhaps with auto-notfications when something has been added/changed), this way the comunity may answer some questions (and not everything's up to you) and some developers might be drawn into the boards/comunity. 2. I don't think the plugins are to expensive. I think it's more of a question whether people need it and/or undestand what it's good for. Casual-Me for example can't really grasp the power/need of Particle-Storm, because I have only half a clue about how/when to use particle-systems, or where they'd made my life easier. 3. I actually love the magazine-style of Interphase. Magazines not only give you the articles you wanted, but also broaden your horizont with topics you wouldn't have looked into otherwise. I think choosing which articles to buy, would take this away and make purchasing it more complicated. Scrooge-Me would try to find the best mix of price, must reads and might-be-interesting articles AND then, instead of buying it, come back another day to review his choices. once again. before actually buying it
  4. A short tutorial for a plugin, I have no clue whether you can use it 1-to-1 on your code: http://codetowin.io/tutorials/phaser-plugins-the-making-of-camera-shake/
  5. Perhaps show some bubbles floating upwards from the person. The faster the persons sinks, the faster the bubbles go upwards...
  6. I tend to think in "gamestates" (Walking around on the Map? Inventory? GameOver? Combat-Mini-Game? Pause? GameStates! All of them ), so I would love this. Could be a bit more "Stack"-like (push and pop instead of start and kill), but I guess that's semantics. Would also be nice to give input variables (IIRC that's already possible) and to give back results, say: game.state.start("PlayingTheGame", true, bunch of other params);...game.state.push("lockPickerMiniGame", ... , kindOfLock);...game.state.pop(PickLockResult);
  7. If you're using physics, maybe use gravity.x?
  8. Looks very nice. Is the enemy movement server- or client-based?
  9. Don't open the file(s) seperately, but the containing folder (File->Open Folder). Then select your "index.html" on the left and hit the live-icon (looks like a little flash on my system) on the right.
  10. Usually I get this errors because, "this" isn't what I expect it to be. 'this' isn't the function, but the context ("owner") of the function. In your case "this" isn't the game state, but "BasicGame", try the following and you might see: BasicGame.gameState = function (args) { console.log(this,args);};EDIT: However, that's just the "why" of the error (encapsulating the gamestate in BasicGame changed the owner to the unexpected), not how to work around it. Encapsulating the various states in it's own container certainly has it's charm.
  11. Not for a whole game, but a cool tool for dialogues: https://github.com/Kibo/dialoguesBuilder
  12. I think JSON needs to be encapsulated by an actual object, so instead of this array... [{"bg":"day","spawn":[...]},{"bg":"day","spawn":[...]}]...try this.. { "data":[ {"bg":"day","spawn":[...]}, {"bg":"day","spawn":[...]} ]}
  13. I bought the "Book + Code"-bundle. The book (I used the PDF, there are ebub and .mobi-versions in the package as well), has a one-column layout, 128 pages, never looks to cramped and is easy to read. Sometimes it breaks code over more than one page where it would have been possible (and nice) to simply start on a new page (like on Page 8/9 in my version of the book). To understand the book, you'll need to know a little bit of html and of course javascript, which the book also states. The book begins with what Phaser is, what you need to set it up and how to get a game project started. It could be a bit more comprehensive on some of these points (How to set up a Webserver could use a little more detail, where is that f*cking Download-Button on Gitghub ), but that's not it's focus, so that's OK. It then proceeds to make a game prototype and builds it up until you have a desktop and mobile-friendly game with animations, sounds, gamestates, touch/keyboard inputs, uses game-maps made with Tiled-Editor and so on. I think the only thing I'm missing would be, "scrolling" (Levels with more than one screen), but besides this, and the limitation, that it only makes use of Arcade-Physics, it looks really comprehensive and delivers it's topics in easy to digest portions. The books ends with the whole total source-code of the finalised game and some suggestions/tips where to go from there. All in all I think it's a really great guide to start phaser. I guess you could find most of the thing explained in online-tutorials, but having them in one easy to digest book is really nice to have and 29$ seems a good price for it, and I wouldn't question the price, if it wasn't for the bundle. The bundle "+ Code" is exactly what the page says: The final code of each chapter from the book in executable form, a cheat-sheet (which gained an update from ugly .txt to a nicer .PDF) that shows you all the phaser objects (and their methods/attributes) used in the book, as well as an empty template for a game with different gamestates. It did cost an additional 30$, and I'm quite underwhelemed by it. I somehow expected the book to be even more comprehensive when the code is given as a different package, but the code (and if you take a sharp look even the empty game template) is completely in the book and you'll have it, if you work through the chapters. The code in the book, of course takes space of the 128 pages you bought, I guess something around 30-40 pages. Now I'm not sure whether the book is worth less because of said 30-40 pages or I misspent the 30$, but since it's exactly what the Homepage of the book page says, I guess that's my own fault. The cheat-sheet is nice, but not 30$-nice. I think I'll settle with a "thumbs up" on the book, but I can't really recommend the "+ Code" bundle.
  14. A small usability-request: Add an Upload-Button or at least a simple text "Drop asset files here" under assets. I was totally like "Huh!? where/how to begin?" when first opening the Mighty Editor. Thanks and keep up the good work!
  15. IIRC, add WASD with game.input.keyboard.addKey(Phaser.Keyboard.A) ... in the create function and use something like that to ask for the key in the update phase: if(this.cursors.up.isDown || game.input.keyboard.isUp(Phaser.Keyboard.A)) ...