Jump to content

I want to make a leader board


Hosh
 Share

Recommended Posts

Hello , Are you planning to add online leaderboaror offline leaderboard???

about offline

You can try  localStorage to save the score.

 https://www.panda2.io/docs/api/Storage

https://www.panda2.io/examples#storage-get

 

about online, you need to use server side programming languages

if your game export to mobile device, you can integration Google play services

 

hope can help

Link to comment
Share on other sites

15 hours ago, Hosh said:

but how can i also make a text field and take player name ??

For example, like this: https://plnkr.co/edit/CJ9iGJr4mkysO5t0?preview

<!doctype html>

<html>
    <body>
        <input id="nameField" value="Enter your name...">
        <button id="okButton" onclick="okButton_OnClick()">Ok</button>

      <script>
          function okButton_OnClick() {
              var nameField = document.getElementById("nameField");
              var name = nameField.value;
              console.log(name);
          }
      </script>
    </body>
</html>

 

Edited by 8Observer8
Link to comment
Share on other sites

@Hosh

Try this example, simple way to make player input his name

Control:

Keyboard: input you name

Enter: Enter your name  (only input number and alphabet )

game.module(
    'game.main'
)
.body(function() {

game.createScene('Main', {
    init: function() {     
        this.Name = [];
        this.InputField = new game.SystemText('Enter Name:');
        this.InputField.size = 30;
        this.InputField.addTo(this.stage);
        
        this.YourName = new game.SystemText('');
        this.YourName.position.y = 50;
        this.YourName.size = 30;
        this.YourName.color = 'yellow';
        this.YourName.addTo(this.stage);
    },
    keydown: function(key) {
      if(key === "BACKSPACE" || key === "DELETE"){
      this.Name.pop();     
      }else if(key === "ENTER"){
      this.YourName.text = "Your Name: " + this.Name.join("");  
      }      
      else if(window.event.keyCode > 48 && window.event.keyCode <90){   
      this.Name.push(key);
      }
      this.InputField.text = this.Name.join("");
       
    }
});

});

 

Hope can help

Edited by khleug35
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...