Jump to content

chongdashu

Members
  • Content Count

    118
  • Joined

  • Last visited

  • Days Won

    2

chongdashu last won the day on October 30 2015

chongdashu had the most liked content!

About chongdashu

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling

Contact Methods

  • Twitter
    chongdashu

Recent Profile Visitors

1683 profile views
  1. This looks like a typo, which would cause an error else (this.cursors.down.isDown) { this.player.body.acceleration.setTo(0, 0); }If you change the else to an else if, things should work. Here's a fiddle: http://jsfiddle.net/chongdashu/mq8bg9sf/2/ Also, on a related note, this needs to be fixed too: if (this.player.y > this.game.height) player.y = 0; // needs to be this.player.yOtherwise, an error will occur when the player hits the bottom of the screen.
  2. Have you tried the Page Visibility API? More specifically, listening for the "visibilitychange" event? //startSimulation and pauseSimulation defined elsewherefunction handleVisibilityChange() { if (document.hidden) { pauseSimulation(); } else { startSimulation(); }}document.addEventListener("visibilitychange", handleVisibilityChange, false);Source
  3. I suppose what you're saying is whether it would be better to use an atlas frame-based animation vs a particle emitter. For example, maybe for something like a puff of smoke you might consider a 10-frame animation of a growing ball of smoke particles vs. actually spawning 10 growing balls of smoke? Disclaimer: Just my thoughts, not 100% sure if it's true. If this is what you mean, the frame-based animation will probably be a little bit faster compared to the particle system (blitzing sequences of images vs computing positions and updating them). However, the particle-based system will giv
  4. preload : function () { this.game.load("background", "res/background.png"); this.game.load("character", "res/character.png"); } create : function () { // create layers this.backgroundLayer = this.game.add.group(); this.spriteLayer = this.game.add.group(); // add stuff to layers var bg = this.backgroundLayer.create(this.game.with/2, this.game.height/2, "background"); var sprite1 = this.spriteLayer.create(0, 0, "character"); var sprite2 = this.spriteLayer.create(10, 0, "character"); var sprite3 = this.spriteLayer.create(20, 0, "character"); }
  5. The easiest way to do that would be to continually append a viewport's width-worth of content at the end of the level each time the player traverses through it. * - - - * - - - * - - - *| | | || P | | |* - - - * - - - * - - - ** - - - * - - - * - - - *| | | || P | | |* - - - * - - - * - - - ** - - - * - - - * - - - *| | | || |P | |* - - - * - - - * - - - * * - - - * - - - * - - - * | | | | | P | | | * - - - * - - - * - - - * |
  6. Could be the fact that their sprite is green. The tint is additive, and would end up making the entire sprite dark. @jmp909, could you try with a greenish sprite?
  7. Well, you sort of answered it yourself As jmp909 stated correctly above, this would refer to the state object. I agree that Phaser dynamically linking the core references in the Phaser.Game object to the Phaser.State object can throw some people off. But as jmp909 above again remarks, it does have benefits. For me, I prefer to explicitly reference the loader from the game object (e.g., this.game.load) as opposed to through the state object (e.g., this.load) because it helps me to be explicit where all the core modules are coming from.
  8. There are many ways to do it, and if you post what your code is like currently, we'll be able to give more direct advice. But you could simply do something with a timer, or a countdown: var lastClickTime = game.time.elapsed;// ... awesome code herebutton = game.add.button(0, 0, 'button', onClick, this);// ... more awesome code hereonClick : function(e) { var clickElapsedTime = game.time.elapsed - lastClickTime if (clickElapsedTime >= 1000) { // if at least one second has passed, perform action doSomethingAwesome(); lastClickTime = game.time.elapsed; } }
  9. There is the Phaser.TweeManager that I believe is what you're looking for. I'm really sorry, but I'm still not entirely clear what you're trying to achieve based on your explanation, so I might be wrong. But if you are initiating 4 or 16, perhaps you could do something like: for (var i=0; i < 4; i++) { var tween = destroyMe.game.add.tween(destroyMe.scale).to({ x: 0.1, y: 0.1}, 100 + i*100, Phaser.Easing.Back.Out, true, 100); tween.onComplete.add(function (obj, tween, destroyMe) { destroyMe.destroy(); }, this, null, destroyMe);} Wouldn't that achieve what you want - which is to stagg
  10. @drhayes and @jmp909 have both suggested better alternatives to the way that you are currently handling this. You might want to consider them after getting it to work! Anyway, there are two problems in your code. Problem 1 Your variable i is never decrementing below 3. Try putting a console.log(i); after if (i > 0) in fireBullet(). You will see that it never drops.So let's take a look at where i is ever modified. Since it's not being modified in fireBullet()'s loop, it has to be in the update() of your Sprite.There is a check for if (game.time.now > delay) { i = 3; } so it's likely
  11. Aha! Nice find, @jmp909. Didn't think that Phaser had a pixelPerfect thingum! Thanks too!
  12. Disclaimer: This is just going off what I saw in the docs. I've not done this before What you need to do is first define the polygonal shape. Since you have a trapezoid, it'll probably be something like; // (0, 0)// * // | *// | * (10, 4)// | |// | * (10, 8)// | * // *// (0, 12)var vertices = [ 0, 0, 10, 4, 10, 8, 0, 12];var polygon = new Polygon(vertices);var sprite = this.game.add.sprite(0, 0, "button");sprite.hitArea = polygon;I didn't go into too many details - I'm not sure whether the polygon is in local space or in wor
  13. No, it's important to differentiate between class and object. Do not worry about the language for now, because classes and objects are an abstract concept that other programming languages either support natively or can be implemented. An object is an instance of a class: Think of a class as like a definition (e.g., schematic or a blue print.) It represents an abstract concept. Hence in my example: the Soldier class is a definition to represent a soldier.the definition is that a soldier has both a height and a weightAn object is a concrete instantiation of the class. The objects in my exampl
×
×
  • Create New...