Code4Breakfast

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. I am working on a boss movement method. The idea is that every 8 seconds the method will be called from the create method, this may be part of the problem... The idea is that every 8 seconds the method will be called. The boss will appear from one side of the screen and exit to the other. The bosses y coord will be based on where players y coord. The issue I am running into is that when the level starts the boss starts moving before 8 seconds goes across the screen to exit and is never seen again. I am not moving the player during the test so the bird isn't going beyond the y screen parameters. The console is only logging the side once so it only seem to be getting called once. My relevant code below: // inside the create method this.blueBirds = this.add.group(); this.blueBirds.enableBody = true; this.multiBlueBirdFlight = this.game.time.events.loop(Phaser.Time.SECOND * 8, this.flyBlueBird(), this); // inside the game state flyBlueBird: function () { var blueBird = this.blueBirds.getFirstExists(); if (!blueBird) { blueBird = this.blueBirds.create(this.X_MIN, this.player.y -100, 'blueBird'); blueBird.anchor.setTo(0.5); blueBird.customParams = {}; blueBird.customParams.side = 'left' blueBird.body.allowGravity = false; blueBird.animations.add('flying', [0,1,2,3], 5, true); } if (blueBird.customParams.side == 'left') { blueBird.reset(this.X_MIN , this.player.y - 100) blueBird.body.velocity.x = 100; blueBird.body.velocity.y = -10; blueBird.customParams.side = 'right'; } else { blueBird.reset(this.X_MAX + 50, this.player.y - 100); blueBird.body.velocity.x = -100; blueBird.body.velocity.y = -10; blueBird.customParams.side = 'left'; } blueBird.play('flying') console.log(blueBird.customParam.side) }
  2. My onscreen controls are disappearing after I add (fixedToCamera = true;) to each of the buttons. I do not see any errors in the console, so I assume the buttons are moving off screen or something. The Camera is set to follow the player in the create method. The on screen controls works fine until I try to get them fixed to the camera to follow the along with the player. Any insights into what is happening would be extremely helpful. onScreenControls: function() { // on screen controles for direction this.leftDirec = this.add.button(40, 1140, 'directionalButton'); this.leftDirec.anchor.setTo(0.5); this.leftDirec.alpha = 0.5; this.middleDirec = this.add.button(80, 1150, 'directionalButton'); this.middleDirec.anchor.setTo(0.5); this.middleDirec.angle = 90; this.middleDirec.alpha = 0.5; this.rightDirec = this.add.button(120, 1140, 'directionalButton'); this.rightDirec.anchor.setTo(0.5); this.rightDirec.alpha = 0.5; // on screen controles for actionButton this.actionButtonOne = this.add.button(240, 1150, 'actionButton'); this.actionButtonOne.anchor.setTo(0.5); this.actionButtonOne.alpha = 0.5; this.actionButtonTwo = this.add.button(320, 1150, 'actionButton'); this.actionButtonTwo.anchor.setTo(0.5); this.actionButtonTwo.alpha = 0.5; this.actionButtonThree = this.add.button(280, 1125, 'actionButton'); this.actionButtonThree.anchor.setTo(0.5); this.actionButtonThree.alpha = 0.5; this.actionButtonFour = this.add.button(280, 1165, 'actionButton'); this.actionButtonFour.anchor.setTo(0.5); this.actionButtonFour.alpha = 0.5; //controls for jumping this.actionButtonFour.events.onInputDown.add(function() { this.player.customParams.mustJump = true; }, this); this.actionButtonFour.events.onInputUp.add(function() { this.player.customParams.mustJump = false; }, this) //controls for move left this.leftDirec.events.onInputDown.add(function() { this.player.customParams.movingLeft = true; }, this); this.leftDirec.events.onInputUp.add(function() { this.player.customParams.movingLeft = false; }, this) this.leftDirec.events.onInputOver.add(function() { this.player.customParams.movingLeft = true; }, this); this.leftDirec.events.onInputOut.add(function() { this.player.customParams.movingLeft = false; }, this) //control for move right this.rightDirec.events.onInputDown.add(function() { this.player.customParams.movingRight = true; }, this); this.rightDirec.events.onInputUp.add(function() { this.player.customParams.movingRight = false; }, this) this.rightDirec.events.onInputOver.add(function() { this.player.customParams.movingRight = true; }, this); this.rightDirec.events.onInputOut.add(function() { this.player.customParams.movingRight = false; }, this) //fixedToCamera this.actionButtonThree.fixedToCamera = true; this.actionButtonTwo.fixedToCamera = true; this.actionButtonOne.fixedToCamera = true; this.rightDirec.fixedToCamera = true; this.middleDirec.fixedToCamera = true; this.leftDirec.fixedToCamera = true; this.actionButtonFour.fixedToCamera = true; }
  3. I am working on my first phaser project. I am making a vertical scroller game utilizing a different gameState for each level, but I would like the next level to have the orientation rotated from a 360 x 592 to a 592 x 360. The original game object I created was 360 x 592. I assume that I have to make a second game object for the horizontal GameState levels and can reuse the object, but was wondering if what the potential issues are for going back and forth, or if anyone wants to comment on their experience designing something like that.