• 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

3308 profile views
  1. I was working on a game in Phaser and I was targeting the desktop. My plan was to wrap in Electron. Ultimately, the memory usage of Chromium before it had even loaded my game proved very restrictive (hovering between 500 and 800 megs and I hadn't even loaded music assets yet!). I made the decision to switch to love2d for my desktop game, unfortunately. The main factor in my decision was that I was using Phaser (and a browser) in a way that wasn't congruent with the browser or my goals. Phaser's a great game engine, especially for making games that feature things that the web is *really* good at: anonymous users, free games, online play of any kind (slither.io or multiplayer or whatever). That's not a restrictive or exhaustive list, I'm just saying that not enough games for the web exemplify the ethos of the web, if that makes sense. I think that's why all those .io games (agar.io, slither.io, etc) are so popular: instant play, massive multiplayer, short attention spans. Ultimately, outside of hard technical limitations, I think you could do whatever you want with Phaser. EDIT: And I meant to say that the community around Phaser is really great; it should be considered a feature of the engine. Lots of skilled people hanging out on the forums and willing to help.
  2. 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.
  3. drhayes

    AsterWaster Game

    This is cool! Thanks for open sourcing it.
  4. drhayes

    Physics glitch

    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.
  5. 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.
  6. 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.
  7. 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".
  8. 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
  9. 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?
  10. 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);".
  11. 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?
  12. 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.
  13. 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.
  14. 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. ( =