Quest gridApi stuff (QuestJS)

K.V.

Help!

How does gridApi end up pointing to something with all the functions?

I assume something changes the onLoad function, then calls the onLoad function, hence setting up all the other functions. Otherwise, it's just an empty object. Well.. an object with one empty function.

I ask this because I'm trying to make the maps work when compiling with QuestJS.

// GRID FUNCTIONS ***********************************************************************************************************************

// gridApi is global for interop between PaperScript and JavaScript - a workaround until
// this tutorial exists: http://paperjs.org/tutorials/getting-started/paperscript-interoperability/

window.gridApi = {};
window.gridApi.onLoad = function () {
};

_canvasSupported = (window.HTMLCanvasElement);


The functions of gridApi are mostly defined in grid.js.

functions like gridApi.setScale = function(newScale) {.
It would probably be easier to read if all the gridApi functions were put together, but at present they're interleaved with global functions.


K.V.

I think most of the functions are in grid.js (as you say, mrangel), and some are in playercore.js. (If there are any more, I can't find them, but that doesn't mean they don't exist.)

I see where paper.js has a script element linking to it in the HTML, but not grid.js. So, I added one for grid.js, and that caused all sorts of other errors...

I will post a link to the files after converting a game with a map. I'll also post a link to the same files, only modified to the best of my ability in an attempt to make the map work. (Ugh. I don't even like the map! ...but some games have maps, so QuestJS needs to be able to handle it.)

I probably have it loading files in the wrong order or something silly like that.


If the map issue were resolved, the only problem with QuestJS would be having this in a script dictionary attribute, and I can post an easy fix for that.

There are other little quirks, of course, but I have notes (somewhere) which can be added to the wiki.


Just for fun, I'll tell you about one of the quirks. You can't combine lists with list1 + list2. This produces a string (as you may have already guessed).


K.V.

I found some gridApi functions in the game's HTML, too.

Now I've got less errors...

At the moment, this stops the game from loading:

TypeError: paper.view is null

function ShowGrid(height) {
    _showGrid = (height > 0);
    $("#gridPanel").show();
    $("#gridPanel").height(height);
    $("#gridCanvas").prop("height", height);
    paper.view.viewSize.height = height;
    $("#gamePanelSpacer").height(height);
}

paper is defined, but not paper.view


In quest.js, we have:

        var paperScript = document.createElement('script');
        paperScript.setAttribute('src', 'ui/grid.js');
        paperScript.setAttribute('type', 'text/paperscript');
        paperScript.setAttribute('canvas', 'gridCanvas');
        document.head.appendChild(paperScript);

So that's <script src="ui/grid.js" type="text/paperscript" canvas="gridCanvas" /> if you're not adding it dynamically.
Not sure if it's still an issue, but I think there was something about paper.view not being created if the specified canvas element hasn't already loaded. So you need to ensure this script is loaded after the canvas exists.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums