Getting Started

  • plamzi
  • plamzi's Avatar Topic Author
  • Offline
  • Administrator
More
15 Aug 2013 22:08 - 19 Jun 2015 06:21 #1 by plamzi
Getting Started was created by plamzi
Getting Started:

Customizing the Portal app is the recommended way to create a unique web experience for your game. You can do that entirely through this website, using an online code editor, and checking your work in your browser's console log .

Step-by-Step Guide:

1. Navigate to User Menu -> Articles & Scripts . Optionally, review some examples by clicking on script names.

2. Make a copy of Bedlam-Init.js by clicking on the copy icon.

3. Click on the edit icon to edit your new file, which will be placed in the category "App Code / Private". Rename it to anything you desire, just make sure it ends in .js.

4. Click on the "Metadata" tab. Change the values under "Meta Keywords" to list all the servers and ports for which you would like this script to load.

5. Delete everything except the first 7 lines of the script. Then hit "Save & Close". Ensure that your script is in a "Published" state.

6. Access the app "play" URL for your game. If your app is listed, you can just use the links inside the listing or inside the app Game Center. If not, you can modify the host= and port= parameters of another game's link.

7. If you have the console log open, you should see a notification that your script has loaded on the page. It should produce a very clean app look, and it will change the background of the app page.

Optionally, add the parameter &debug=1 to the app URL to enable verbose logging to the browser console. Debug your script by making changes to it from "Articles & Scripts." Follow the Web App API Documentation to ensure that your customizations are effective and robust.

When ready to publish, move the module to the App Code / Official category using the Publishing tab in the editor. If you don't see the Official category, contact the site admin for an account upgrade and specify the server / port you wish to publish customizations for.

Publishing a module under "Official" means that all users who have opted to trust official code (default) as well as any guests (e. g. people you drive to the app via a deep link ), will get the new plugin when they access your game.

Best Practices

Built-in plugins follow the Module Pattern . It's ideal for apps with many interlocking parts by many developers. You don't have to follow it, but it would be a good idea.

Basic Event Hooking
Event.listen('scrollview_ready', function() {
    j('.app .out').css({
        fontFamily: '"Open Sans", "DejaVu Sans", "Lucida Console", sans-serif',
        fontSize: 14
    });
});

The above code adds a listener to the 'scrollview is ready' event, and changes its font and font size. Hooking to this event ensures that the scrollview has finished initializing before you run your code.

Events Documentation
Last edit: 19 Jun 2015 06:21 by plamzi.
The topic has been locked.