• Content Count

  • Joined

  • Last visited

About jzcodes

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello, I'm working on a racing game and I have a character select screen that allows the player to choose between 3 variations of the same character (blue, pink, purple). In my main.js I have a global variable to hold the character value (blue, pink or purple). In stateChoice.js I have 3 buttons, and I am using .bind. When the player chooses the global variable becomes whatever color they picked. However, in my mainState.js I have the game and I'm currently using a ton of repetitive code to say if (character == 'blue') { // add this sprite , etc. etc.}. Obviously, this is not ideal since I am repeating a ton of code for all 3 characters. I did some reading on extending sprites but, the examples I've seen are for the same sprite now different ones. How do I go about adding a sprite (any of the colors) in a way that I can do everything once in the main game?? Thank you! //BUTTONS TO CHOOSE CHARACTER //Choose Racer1 this.pickRacer1 = game.add.button(game.world.centerX-150, game.world.centerY+105, "buttons", this.racerStart.bind(this, "blue"), this); this.pickRacer1.anchor.set(0.5, 0.5); //Choose Racer2 this.pickRacer2 = game.add.button(game.world.centerX, game.world.centerY+105, "buttons", this.racerStart.bind(this, "pink"), this); this.pickRacer2.anchor.set(0.5, 0.5); //Choose Racer3 this.pickRacer3 = game.add.button(game.world.centerX+150, game.world.centerY+105, "buttons", this.racerStart.bind(this, "purple"), this); this.pickRacer3.anchor.set(0.5, 0.5); //BUTTON FUNCTION racerStart: function (racer){ console.log(racer); for (var key in this.buttons) { this.buttons[key].frame = 0; } this.buttons[racer].frame = 1; character = racer; this.startConfirm.animations.play("neon"); // character.animations.play("blue"); console.log(character); },
  2. @Garlov Oh! That is really interesting!! I've never heard of this before and I can't wait to look into it, this sounds perfect!! Thank you so so much!!!!
  3. Hi, I'm still pretty new to Phaser and I'm making a character select screen that shows all of the characters (only 3). Each one has a button that looks like a power on/off switch. When you click the button it should toggle the button to the correct frame ("on"), but if you click another character it should switch "off" the button of the previously chosen character and turn the currently chosen button to "on." The toggling was one issue, this was the best thing I could think of (it works, but it ends up being repetitive since there are 3 characters): //Button this.pickPink = game.add.button(game.world.centerX, game.world.centerY+105, "buttons", this.pinkStart, this); this.pickPink.anchor.set(0.5, 0.5); //Start with Pink pinkStart: function () { if(this.pickPink && character !== "pink"){ //set button frame to "ON" this.pickPink.frame = 1; character = "pink"; } else if(this.pickPink && character === "pink"){ //set button frame to "OFF" this.pickPink.frame = 0; character = undefined; } console.log(character); }, But now I need to figure out how I would detect that if another button gets picked, turn the previous one (or all others) to OFF. I don't want more than one of these toggled on at a time. Is there anyway of achieving this? Many thanks and much appreciated!!
  4. I figured it out!! It was a little tricky to find a clear description of the params but, this is what I did! var tween1 = game.add.tween(this.countDown1).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false, 0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0); var tween2 = game.add.tween(this.countDown2).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false, 0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0); var tween3 = game.add.tween(this.countDown3).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false, 0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0); var tweenGo = game.add.tween(this.countDownGo).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false, 0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0); tween3.chain(tween2); tween2.chain(tween1); tween1.chain(tweenGo); tween3.start();
  5. Hello, I'm making a racing game (at least I'm trying to!) I'm using a setTimeout function to delay the start of the scrolling of the background by 3 seconds which works perfectly! But, what I really need now is to display an image of "3" *pause & fade out*, switch to image of "2" *pause & fade out*, switch to "1" *pause & fade out* then show "Go!" * fade out* I saw something where I set the alpha to 0 and then tween the alpha to 1 like so: game.add.tween(this.countDown).to({alpha: 1}, 1000, Phaser.Easing.Linear.None, true, 0, 1000, false); But this isn't exactly what I'm looking for. I'm not sure what all of these parameters are or how I would switch between the images (using different images or a spritesheet, I'm not sure what's best) to give the desired effect. Can someone please help me? Many thanks, and let me know if you need me to explain this better! Update: I kept hunting around (I apologize for not searching more thoroughly) but, I did come across chaining tweens. I'm trying it out but having some difficulty
  6. Ohhh okay awesome!!! I figured I would have to use some sort of timer but I've never used them in Phaser before!! And I just so happened to watch a video on a scrolling background the other day. Thank you so much ! I can't wait to play with this!
  7. Hello! I wasn't sure what to call it but I am working on a game with my husband (terrible idea, he's a designer..) and he asked if I could create a menu screen that plays out a little scene or something. He showed me this video as an example of Mario Kart SNES (only watch the first 35 seconds of so): https://www.youtube.com/watch?v=AlAmXXNz5ac I am aware of how to use states and all but, I only just started using Phaser and I was trying to think out how I would create something similar to the scene played out in the example (Maybe something not so complex), also if this is possible how would I loop this scene, since a user might leave the scene playing to see the end of it? Thank you in advance for all of your help!!