Jump to content

On Screen Controls Disappearing


Code4Breakfast
 Share

Recommended Posts

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;

  }

 

 

Screen Shot 2016-07-13 at 11.53.57 PM.png

Screen Shot 2016-07-13 at 11.52.54 PM.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...