• 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

Contact Methods

  • Website URL
  • Twitter

Profile Information

  • Gender
    Not Telling
  • Location
    Austin, TX

Recent Profile Visitors

1,500 profile views
  1. That explains problems I've had with start for forever. I never get exactly what I want the first few times and always have to dig in. Thanks for letting me know about those methods.
  2. This is cool! Thanks for open sourcing it.
  3. This is a common fail state in 2d physics engines. The engine usually has to have special code to overcome this. Phaser's special code is in its Tilemap implementation. I would suggest making your blocks a Tilemap (even if you have to generate it dynamically) and going from there. What's happening is that the physics engine tries to move your sprite by its velocity. Each dimension (x and y) are exactly the same mathematically: add the velocity * time delta to the position and you're done. However, there are two components to velocity, so which one do we do first? Phaser picks a really common one: do y first (we're more often standing on floors than sliding down walls, if you get me). The side effect is that your sprites can catch on edges like you're seeing. Since the sprite's velocity is, say, (5, 5) the sprite's AABB body tries to move diagonally downwards to the right. First we check y, then we check x. Checking y we see that the wall is there, intersecting the right side of our AABB body! So we stop downwards movement entirely. And there's your bug. The best way around this that I know (and that Phaser uses in its Tilemap implementation) is to declare particular edges in a map as "uninteresting" so they don't get checked for collision. The most important edge in your wall of solid vertical tiles is the left one, not each edge between each adjacent tile. This prevents the problem from happening. But Phaser doesn't want to generalize that behavior across a bunch of individual sprites for performance reasons. Sprites move all the time, have different sizes, etc. Ah, but Tilemaps! All the same size, all not moving. And there you go. Here's the function in Tilemap that does just what I described and finds "interesting" edges on Tiles. It saves them by modifying the tiles' face* properties.
  4. Might be worth creating a TileSprite that's the width/height of your canvas and adding it directly to the Stage, behind the World. It should tile the same way and will obey the regular ol' canvas fullscreen.
  5. It's okay, this stuff is confusing. Phaser declares a global object named "Phaser" more or less like this: "window.Phaser = window.Phaser || {};". That means "assign to the Phaser property on window the already existing value of window.Phaser. If there's nothing there, assign an empty object to it instead." That's a good way of making it assign an empty object if there's not one already. You'll see this everywhere in JavaScript code. After that, there's code in the Phaser library that keeps adding functions and objects to this top-level thing: "window.Phaser.State = ..." and "window.Phaser.Sprite = ...". That builds up all the classes you have available to you in Phaser. Your declaration of "gameState" is called an object primitive. It's a great way to make objects in JavaScript. You are the one defining those functions on it (i.e. preload, update, etc.), not Phaser. This object eventually gets passed to the Phaser StateManager through a call to add: https://github.com/photonstorm/phaser/blob/1bad8811396ba1062ab3dcdcbbf6a9d0d7cd5391/v2/src/core/StateManager.js#L193 Eventually, the StateManager "fills in the blanks" and sets a bunch of useful properties on the object you created: https://github.com/photonstorm/phaser/blob/1bad8811396ba1062ab3dcdcbbf6a9d0d7cd5391/v2/src/core/StateManager.js#L459 It then uses those functions you defined to run your game: https://github.com/photonstorm/phaser/blob/1bad8811396ba1062ab3dcdcbbf6a9d0d7cd5391/v2/src/core/StateManager.js#L530 The best way to learn the hierarchy is to read the docs: http://phaser.io/docs/2.6.2/index The front page has a column, "via". That is the name of the property on the game and, usually, the state objects: game.add, game.make, all those things. Check it out.
  6. You can add a custom collision method to the tiles you care about -- when something (e.g. the player) touches them it'll call your callback. The method you want is "Phaser.Tilemap.setTileIndexCallback".
  7. Here's another vote for Pyxel Edit. Runs using the Adobe AIR runtime so it's very cross-platform. I'm a little worried because I don't think it's been updated recently. Another thing to like about it is the file format is really simple. I made an exporter so I can make my sprite atlases from the command line by using the "raw" Pyxel Edit files: https://github.com/drhayes/pyxel-edit-cli
  8. Yeah, quoting from the docs for Phaser.Loader.start: So that's weird. Can you use 2.6.2 instead of 2.5? See if there was a bug there, or something?
  9. I don't know how your AI knows that it's the AI's turn, but you could put a timer on that function instead of calling it directly. Check out Phaser.Timer. There's a pretty good timer available at "game.time.events". You can do something like "game.time.events.add(5000, this.takeAITurn, this);".
  10. You shouldn't need to start the loader manually at all by calling "game.load.start()". Where did you put that that your code started working?
  11. You've got the sprite's constructor wrong. It's not "constructor({game, x, y, key, frame})" it's "constructor(game, x, y, key, frame)". Note the missing curly braces. Your call to super is fine, though.
  12. Don't modify the player's and the rock's positions directly -- change their velocities. If they don't have velocities then they won't overlap/collide correctly.
  13. You're correct -- the main use of modifying a particular function's prototype is to share the memory taken by those functions across a lot of instances of that function's prototype. Not making more than one? Not doing inheritance? Totally a style thing. ( =
  14. It is possible but it's not Phaser-specific. I would start with this HTML Rocks article about capturing audio and video. Now that you have the video you'd need to upload the image somewhere, find the URL, tell Phaser to load it as an asset, wait for it to finish loading, then add it as a Phaser.Image. Or, you could probably grab the image directly and add it to Phaser's Cache yourself instead of bouncing it through the loader. That wouldn't save the user's image, though.