breed

Members
  • Content count

    24
  • Joined

  • Last visited

  1. So close! when you're using the bracket syntax, you don't put a dot before it. So it should be this['wave'+i].whatever
  2. Sure is! Just use the `addChild` http://devdocs.io/phaser/phaser.sprite method for the sprite. You can add the hpbar as a child sprite to the enemy.
  3. Sure. I'm assuming your player object is a Phaser.Sprite. In this example https://phaser.io/examples/v2/sprites/move-a-sprite the update method accesses the sprite's 'x' and 'y' properties, which represent the sprite's location.
  4. It seems like you should take a look at Phaser's documentation and some of its examples. There's a level of fundamentals that you need to understand in Phaser before you're going to have any success with it. Something like finding a players' coordinates can be looked up in the documentation or the examples, and looking that up yourself will build your skills in both Phaser and finding the answers to your Phaser questions. I'm not trying to discourage you from asking questions on the forum - the Checkpoint question was a fantastic one! There's all kinds of ways to implement it and there's a great discussion to be had in the forums about it. But when it comes to the basics of Phaser or any library or framework really, you're better off attempting to look up the documentation or googling around to answer your question first rather than asking for help too soon.
  5. I'd make a Checkpoint class and a CheckpointStore class, then whenever the player passes through a checkpoint in the game make a new Checkpoint and put it in the CheckpointStore. When the player falls in to a trap and dies, ask the CheckpointStore for the last saved Checkpoint and restore the player and gamestate to what's saved in that Checkpoint. Obviously there is a lot more detail necessary for this approach, but that's a high level way to look at it. (Also the term "store" here I'm using by the definition of "a place to keep something" rather than "a place to buy something")
  6. edit: nvm, misread the code
  7. I believe there's a 'moveTo' or 'moveToward' method lying around somewhere, probably on the Phaser.Sprite class. I'm on my phone now so I can really search for it in the docs, but when you find it, you can probable call that in the update method for your sprite so it gets called every game loop
  8. Oh wow it is! Geez I didn't realize all the modern ones were so up-to-date with ES6 features. Yeah so if you are good with only supporting modern browsers, go for it. If there's older browsers you want to support, you'll need to do a little extra.
  9. Yeah that's an ES6 thing, so you'll need to use a transpiler for that
  10. Might be something to do with Phaser trying to smooth out the image? There are options I think in the Phaser.Game constructor and on the Phaser.Stage object that allow you to turn off anti-aliasing and smoothing. Maybe someone else can give more specifics on that.
  11. This is the important error: Failed to load resource: the server responded with a status of 404 (Not Found) the second error stems from this one. It's saying that your server is unable to find a file you're requesting, either 'assets/level8.json' or 'assets/tiles-1.png'. Double check that both those files are present on the server. You could also check the "network" tab in the chrome developer tools and look for which request failed to find out which file is the issue. Either way, this doesn't seem like a coding error with Phaser, it seems like a misrequested file or server configuration error.
  12. It's good to have an example like that to show the concept of verifying something unique to the site to make sure the code is running on the right page. Still though, it doesn't matter how the value is checked (string or variable or whatever) if it all happens on the client side. If someone is intent on running your code on their own site, nothing will stop them from downloading the JavaScript/images/html from your website and editing the code to make it run on theirs. For this example, that means changing whatever client side value is checked. The only way to make sure that can't happen is to do the verification server side. That's something that someone can't copy just by downloading your JavaScript files. Its a more complex solution, but will secure your content by tying it to the response from your server.
  13. Ah, so by "sitelock" and "url lock" do we mean making sure your game can't be embedded on other websites except your own? Interesting. Unfortunately, symof's method isn't very secure. If a URL had 'domain.tld' anywhere in it (as a query parameter for example) then the code lock would fail. Plus, it wouldn't be too difficult to edit your script to remove that line and make the game work, even if the code is minified. The only solution I can think of off the top of my head is to have the server come up with a random token it sets as a cookie in the browser on page load. Then, when the page requests the assets and JavaScript files for the game from your server, the cookie would be sent along with the requests and the server would verify that its the correct value for the token and serve back the requested files. If the cookie was missing or was a bad value, it would not serve the files and the game wouldn't get loaded on the client.
  14. Something sounds weird here, because if you tried to set the 'mute' property on 'game.sound' when 'game.sound' is null, you'd see an error in the JavaScript console complaining about trying to do something with a null value. You should make sure that code is actually executing, and then if it's not, find the right place to put it.
  15. samid737 is right on the money with velocity being a vector property. The if statement is failing because it's checking to see if the element.body.velocity == 0, which will never be true because element.body.velocity is an object that (roughly) looks like { X: 50, Y: 0 } And that object will never === 0. A good way to debug this would be to console.log both values you're comparing to see what they actually are. Or you could use the debugger in the browser if you know how. I'm not sure what the right way to accomplish your goal is, but this is the crux of your issue.