Jump to content

Phaser with a form?


hollygood
 Share

Recommended Posts

Hi, I'm a Phaser newbie here.

 

I'm building a breakout game, and when the ball hits a specific brick, the game will be paused and a questionnaire form will appear, user needs to select the answer and  submit the form. After the form submission, the game unpause and user goes back to the game again.

 

My current solution is use a pop up window, and load an iframe for the form.

 

I'm wondering if there are another possible solutions.

 

Thanks in advance.

Link to comment
Share on other sites

you need create 2 transparent markers with help game.add.sprite(x,y,sprite). 1 in the left top point and 2-nd in the right-bottom. After that you can fast calculate where must be your html box. This  is code from my current project 

 

enableGui : function (ctx,marker,marker2) {
    this._marker = marker;
    this._marker2 = marker2;
    var gameHeight = ctx.height,
    gameWidth = ctx.width,
    gamePositionX = ctx.canvas.offsetLeft,
    markerOneX = marker.position.x,
    markerOneY = marker.position.y,
    markerTwoX = marker2.position.x,
    markerTwoY = marker2.position.y;

    this.$el.css({
      width : gameWidth-markerOneX-(gameWidth-markerTwoX),
      height : gameHeight-markerOneY-(gameHeight-markerTwoY),
      top : markerOneY+'px',
      left : gamePositionX+markerOneX+'px',
      zIndex : 8,
      position: "absolute"
    });
},

 

this.$el = this is your html block where will be your form

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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