• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by codevinsky

  1. In Tiled: Create a new object layer, and then push the furthest right top button, this will allow you to place tiles as objects: Screenshot Here, any solid colored tile is an object that I can reference later in the code. Then, the json file you export will look like: Screenshot Then in code: // Arguments:// object-layer-name// gid of object to replace// asset key// frame (optional)// exists (optional)// autocull (optional)// group to add to (optional)// CustomClass (optional)// adjustY (optional)'menu-objects',8,'friendlies',2, true, false, this.bugs);Documentation:
  2. Never mind. I talked to the creator of Tiled. I was pushing the wrong button.
  3. drhayes: no. that's what i'm attempting to do right now. However, I'm afraid that my knowledge of tiled lacks somehting to be desired. I've created objects on an object layer, but Tiled isn't exporting a gid for those objects.
  4. What's the best way to go about this? This isn't a "show me the code" question, but more of a theory question.
  5. You have to set: sprite.checkWorldBounds = true;
  6. Everything was created on the canvas. There's no external assets:
  7. I've changed my code to reflect this and when creating a single sprite, this does indeed work. However, attempting to populate an emitter with this doesn't: var bmd = game.add.bitmapData(4,4); bmd.ctx.fillStyle = '#e4c915'; bmd.ctx.beginPath(); bmd.ctx.fillRect(0, 0, 4, 4); bmd.ctx.closePath(); game.cache.addBitmapData('yellowBlock', bmd); // this works var peeBlock = game.add.sprite(10, 10, game.cache.getBitmapData('yellowBlock')); // this emitter should explode with yellow blocks // on click // but it doesn't seem to work emitter = game.add.emitter(100, 100, 1000); emitter.makeParticles(game.cache.getBitmapData('yellowBlock')); // debug emitter, to make sure my code is correct brokenEmitter = game.add.emitter(100, 100, 1000); brokenEmitter.makeParticles('invalidKey'); game.input.onDown.add(particleBurst, this);The particleBurst method is called correctly, but no particles erupt. The emitter's children[] property is populated correctly with 1000 particles, but emitting either a single particle or a particle burst results in no display. Here's the full code:
  8. I've drawn a yellow square on a bitmapdata object: var bmd = game.add.bitmapData(4,4);bmd.ctx.fillStyle = '#e4c915';bmd.ctx.beginPath();bmd.ctx.fillRect(0, 0, 4, 4);bmd.ctx.closePath();Is there a way to add the image data to the game cache so that I can reference it like this? var sprite = game.add.sprite(10, 10, 'yellowBlock');
  9. Part 5 is up:
  10. Adam's correct with one exception: For a sprite to kill itself when it goes out of bounds: var sprite = game.add.sprite(100,100,'sprite');sprite.checkWorldBounds = true;// checkWorldBounds must be enabled for a sprite to kill itself// when it goes out of bounds.// This causes the sprite to check it's position every frame.// It can be expensive, especially if you have a metric buttload of// sprites doing this.sprite.outOfBoundsKill = true;// this will automatically have the sprite call it's own "kill()" method // if it leaves the world bounds.
  11. Agreed. The Bower package points at the correct repo, but the name on the package points back to rich, which is incorrect.
  12. Or, just use Phaser.Button?
  13. Can you share your code?
  14. I've added 2.0.3 to CDNJS.
  15. george: A quick question: How would you determine the speed to set the particles so that they always fired "behind" the sprite, even after rotation?
  16. Can I modify sprite vertices with Filters like the bitmap data wobble example, but with webgl shaders?
  17. Check this out: Phaser: Attach Particle Emitter to a sprite [CodePen] The most important thing to take away is that you can add any game object to a sprite with: sprite.addChild(gameObject);
  18. I've been trying to figure out how to make a trail for my player's (very simple) sprite. this is going to work very well for that with little to no work.
  19. codevinsky

    Timer Issue

    Graphics is completely different than canvas drawing. You'll want to do something like the following: BasicGame.Game = function (game) { this.shadow; this.doflash; }; BasicGame.Game.prototype = { create: function () { this.shadow =,; this.background =,0, this.shadow); this.doflash = true; }, update: function () { if(doflash) { doflash = true; * 1, this.flash, this); } }, flash: function () { this.shadow.clear(); this.shadow.ctx.rect(0, 0,,; this.shadow.ctx.fillStyle = 'white'; this.shadow.ctx.fill(); this.shadow.render(); this.shadow.refreshBuffer(); } };What this is doing is: It's using a bitmapData (this.shadow) for the texture of the newly created background sprite. Each time flash() is called, it clear's the bitmapData's context, draws a large white square, renders it, and refreshes the buffer so the sprite will use the new texture.
  20. I'm confused. Your question doesn't seem to be very obvious. Can you ask again in a different way?
  21. Thanks, guys! I'll probably have part 5 up on friday.
  22. I've been working on this plugin and demo for a few days. I think it's pretty cool and I'd like some feedback. Here's a running demo: ( WASD to move, mose to shoot ) Here's the source and the readme: The Rundown Basically, you can tell the HUDManager to watch a variable in your state's scope and to do a number of things with it. The simplest thing you can do is have the HUDManager add a text label that will change every time the watched variable changes. This is most obvious with a score display: var hud = Phaser.Plugin.HUDManager.create(game, this, 'gamehud');var score = 0;var style = { font: '18px Arial', fill: '#ffffff', align: 'center'};var textHUD = hud.addText(10, 10, style, 'Score: ', 'score');game.add.existing(textHUD.text); Now, every time your score variable changes, the text will update to reflect that. But wait, there's more: Health/Progress bars maxHealth = 10;var sprite = game.add.sprite(100,100, 'player'); = maxHealth;game.physics.arcade.enableBody(sprite);var healthHUD = this.hud.addBar(0,-20, 32, 2, maxHealth, 'health', sprite, Phaser.Plugin.HUDManager.HEALTHBAR);, 0.5);sprite.addChild(;Now, your sprite will have a health bar above itself head that will display, in colors, where the sprite's health sits, like so: There's a few more things it can do, but I'll let you look around for that as you see fit.