• Content count

  • Joined

  • Last visited

  • Days Won


drhayes last won the day on April 14 2016

drhayes had the most liked content!


About drhayes

  • Rank
    Advanced Member
  • Birthday

Contact Methods

  • Website URL
  • Twitter

Profile Information

  • Gender
    Not Telling
  • Location
    Austin, TX

Recent Profile Visitors

1,155 profile views
  1. I don't think it's a problem, but don't forget to use "add" instead of "addChild". I use exactly this strategy in my games (make the groups in the order I want them, back to front, and add children only to those groups) and don't have any problems. Maybe the groups are getting deleted when you change stage and you're re-making them out of order? The z-indexes shouldn't matter at all between groups, only inside the sprite's parent group. I'm kinda stumped. I would make a really tiny example that has this problem in the sandbox or on JSFiddle or something and see if you can reproduce it.
  2. You don't need that null after the 0 unless that is what you're passing as your extra param. Say I have a signal: "this.onCatpants = new Phaser.Signal();" You come along and add a listener like this: "thing.onCatpants.add(this.myCatpantsListener, this, 0, 'a', 'b', 'c');". Now, your function, "this.myCatpantsListener", will look like this: "myCatpantsListener: function(one, two, three, four, five) {}". Then I dispatch it like this: "this.onCatpants.dispatch(1,2);". Your "myCatpantsListener" function will get invoked with one = 1 (from my dispatch), two = 2 (also from my dispatch), three = 'a', four = 'b', five = 'c' (all from when you attached the listener). Make sense? Here's the code for Phaser.Signal.add: https://github.com/photonstorm/phaser/blob/0df61f30572d0cd44916c3f6007b7f1904efb20d/v2/src/core/Signal.js#L256 Trace it through _registerListener to see it create the SignalBinding and how it handles the extra args. Here's the code for Phaser.SignalBinding.execute: https://github.com/photonstorm/phaser/blob/0df61f30572d0cd44916c3f6007b7f1904efb20d/v2/src/core/SignalBinding.js#L109 Check out what it does on line 119 where it concats the params that just got passed and the args from when the listener got added.
  3. I always get this wrong. I hope someone steps in and corrects me. The anchor point sets the "origin" of the texture. When you position a sprite at (x, y), you can use the anchor to determine what pixel that is on your texture. As such it determines where the rest of your texture is. Does that make sense?
  4. It could, but emitters don't have that function. I'm pretty sure you could get the functionality you want by making the emitter a child of the player: "player.addChild(emitter);" Then it's positioned relative to the player, so you could add it at (0,0) and forget about it. That said, if this emitter is for bullets you should check out the Phaser.Weapon plugin built-in to Phaser. It handles *a lot* of this stuff for you. But if you're asking about "trackSprite" you probably already looked at Weapon, so... ( =
  5. Regarding your edit: what graphic sprite isn't working? How is it created and added to a group?
  6. At this point I'm probably the wrong person to ask. @lewster32 wrote that plugin and he's pretty active on the forum. Maybe he'll swing by?
  7. When the player picks a character, where are you storing what they've picked? Since you're already storing that somewhere, you need to make that available to another state, right? There's a couple of choices. 1. You can store it in a global variable or as part of a global variable. Like if your game is called "Adventure!" you could make a variable called "window.adventure = {};". It's now globally accessible across all files. You could then stick an array on this global var and read it anywhere: "window.adventure.playerPicks = [1,2,3,5];" 2. You're already storing the choice in one state and want to pass it to a second state. When you call "this.start('nameOfNextState');" you can pass extra parameters like this: "this.start('stateName', clearWorld, clearCache, arg1, arg2, arg3);" The "clearWorld" and "clearCache" params are for Phaser. "clearWorld" defaults to true and "clearCache" defaults to false, so you could pass true and false there. Then you could pass whatever you want. In your next state, make a method called "init". "init" will receive those params as its arguments: "init: function(arg1, arg2, arg3) {}". The docs might explain it better than I can: http://phaser.io/docs/2.6.2/Phaser.StateManager.html#start Honestly, I use the first option. There's lots of global state that lots of places in my game need access to.
  8. A drag is one down event, a lot of move events, then an up event (usually... screen/canvas edges can make this a little complicated). Why not store the position during the move events during a drag? As far as persisting the data, it depends. Does your game have a server connected to a database? Is it okay if it's only stored in the user's browser (you can use localStorage)? Do you mind it getting stored in someone else's storage (use Firebase)?
  9. Can you provide more details? Is this a tilemap, with a map made in a map editor like Tiled? If so, Phaser doesn't really support slopes in tilemaps. But this plugin looks like what you'd want: https://github.com/hexus/phaser-arcade-slopes
  10. That doesn't sound that heavy to me..? There are some standard approaches, like snapping to grid when the player moves, or snapping to a 1/2 or 1/4 grid. You'd still end up doing some math to figure out how to squeeze through doors. You could also write a custom collision handler that does this for you and "warps" people through the door, maybe? Just spitballing.
  11. The extra args get passed after the args the particular signal passes you. In the case of onInputDown, that's the game object that received the event and the pointer that caused it.
  12. In your code sample, you are passing "this" as the game -- but, later, you write "this.game.add.existing". So is the game instance in "this" or is it "this.game"? Try passing "game: this.game" to your Texto constructor. Also, you don't need to say "this.game = game;" inside your custom class constructor. The Phaser.Text (and Sprite) parent class will do that for you.
  13. Sorry, I'm not clear what you're asking. You want to drag your sprite and log what its new position is?
  14. "body.touching" is for when the body collides with another body. You want "body.blocked" when checking collisions with the world boundaries or with a tilemap layer.