00:00
00:00
Newgrounds Background Image Theme

Someone gifted MetalSlayer69 supporter status!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Newgrounds API - Simple Javascript Guide?

391 Views | 2 Replies
New Topic Respond to this Topic

Does anyone have a link, or can provide a simple guide on using the HTML5/Javascript for the Newgrounds API? I am brain dead, and stupid.


All I need to know is how do I unlock medals, and post to a scoreboard, as well as how to display them.


I've given it a good go for a few hours, and a few different versions of the NewgroundsIO, but I keep hitting my head against a wall.


Thanks!

Response to Newgrounds API - Simple Javascript Guide? 2023-08-07 00:00:13


It's been a long time since I used it in my Phaser game (which is basically just JavaScript) but my recollection is that I got the newgroundsio.js file from the old deprecated version of the API implementation in the /bin subdirectory and put it in a /bin directory of my game, then had code like so at the top of my index.html file before the JavaScript with my actual game:

<script src="bin/newgroundsio.js" type="text/javascript"></script>

Then came the script with my game, including the following lines

// Start NewGrounds.io
var ngio = new Newgrounds.io.core("my_app_id_went_here", "my_aes_encryption_key_went_here");

and later

    if (ngio.session_id != null) {
      if (wonZoom + wonNoZoom > 0) {
        ngio.callComponent('Medal.unlock', {id: one_of_my_medal_ids_went_here});
      }
      if (wonZoom + wonNoZoom == buttonSprite.length) {
        ngio.callComponent('Medal.unlock', {id: another_medal_id_went_here});
      }
      if (wonNoZoom == buttonSprite.length) {
        ngio.callComponent('Medal.unlock', {id: the_last_medal_id_went_here});
      }
    }

TBH I didn't even know JavaScript when I started this for a month-long Phaser jam so I probably wasn't using good programming practices but it seemed to work. Using the newer version at the top of the list on the newgrounds.io page might be better, but I haven't used it myself.


My newsfeed has random GameDev tips & tricks

Response to Newgrounds API - Simple Javascript Guide? 2023-08-07 15:23:44


what helped me getting it working with construct 3 was reading the wiki on this page plus seeing how it worked in other engines and the newgrounds.io discord server


https://github.com/PsychoGoldfishNG/NewgroundsIO-JS


BBS Signature