Wunderforce

Members
  • Content Count

    8
  • Joined

  • Last visited

  1. Wunderforce

    Restarting a Phaser State is Resetting Global Variables

    DOH! I actually am for the parameter in question. I accidentally used a "=" instead of a "==" in a statement. Boy do I feel stupid.... Should I delete this topic/thread?
  2. I have a global object called "params" that stores a lot of important parameters for my game. I define params in a "main.js" file that initializes the game, defines my states and parameters, and then calls my "bootState". For some reason, when I restart my "gameState" (another state, defined in "gameState.js") it resets my "params" object to the values it was initialized with in "main.js". My goal is to change some parameters via "params" in the console, then restart "gameState" and have it reflect those changed parameters. If needed I can provide some example code.
  3. Wunderforce

    Call a global user-defined function with group.callAll()

    Ok, thank you so much! This definitely helped! Now I am wondering if I should be using a tween instead since I want these objects to move a set distance and then 'explode'. Do you think a tween would be more appropriate?
  4. Wunderforce

    Call a global user-defined function with group.callAll()

    So callAll() won't work unless you define the function for the sprite class? Also, I tried the forEach statement and got the following error "TypeError: callback.apply is not a function" at Phaser.Group.forEach (phaser.js:33325). Which looks like phaser itself might be broken. Note this is for CE 2.10.0
  5. Currently I have a group of sprites and I want to make them all fall at the same time. I am trying to accomplish this with the following functions, where the group (here: fallGroup) should fall when the down arrow key is pressed. (and yes, I have already initialized keys in the create() method) I have tried passing multiple versions of the function definition to callAll() (eg. "this.setVel", "game.setVel", ect.) as well as several different contexts instead of 'null' ("this", "that=this, then passing 'that' in", "game", "game.stage", ect.) but so far nothing happens. For some of the combos I get "TypeError: Cannot read property 'setVel' of undefined" others produce no error but also do not call my 'setVel' function. At this point I'm pretty lost as to what to do. Edit: appleYpos, groundYpos, appleTime; are all globally defined variables function setVel(sprite,vel) { sprite.body.velocity.y = vel; } function makeFall(group) { //calculate fall distance and then adjust velocity to meet time goal //note: velocity in physics.arcade is in pixels/sec let dist = appleYpos - groundYpos; let vel = dist/appleTime; group.callAll('setVel',null,vel); } function update() { if(keys.down.isDown) { makeFall(fallGroup); } }
  6. Yeah, I guess it sets the sprites to `embedded` in the internal `Phaser.Physics.Arcade.overlapX()` method if they are not moving. Good thing they included an option to pass a collisionHandler to `collide()` and `overlap()`.
  7. I am new to phaser and thought that arcade.collide() would separate overlapping sprites, but it doesn't. Is there a built in function for this or do I need to write my own? More detail: I am making a small game that randomly spawns apples at a certain y value and random x value across the game window. Sometimes they end up spawning such that they overlap each other. I was hoping that calling arcade.collide() on the group containing the apple sprites would separate them but it doesn't seem to work despite the call to arcade.collide(appleGroup) returning 'true'.
  8. Wunderforce

    phaser auto completion with brackets

    Took me over a day before I realized that you can't get phaser autocomplete to work with Bracket's native tern This does seem to remove some of the native java script autocomplete however. Any tips on getting that back?