I cant run any melonjs games in browsers

361 views
Skip to first unread message

David Henebery

unread,
Mar 9, 2014, 12:47:53 PM3/9/14
to mel...@googlegroups.com
im fairly new at this but me and a friend of mine had been previously tweaking  "https://github.com/ellisonleao/clumsy-bird"   and that had gone mostly fine. But now were after a new project, however after downloading them and going to index.html, the webpage is stuck on loading or pure blank on at least 7 games i have tried, any help would be really appreciated i have no idea why this is or what to do

Aaron McLeod

unread,
Mar 9, 2014, 12:52:49 PM3/9/14
to mel...@googlegroups.com
Can you post the code for the game? Mainly the game.js file and your play screen :)


On Sun, Mar 9, 2014 at 12:47 PM, David Henebery <davidh...@gmail.com> wrote:
im fairly new at this but me and a friend of mine had been previously tweaking  "https://github.com/ellisonleao/clumsy-bird"   and that had gone mostly fine. But now were after a new project, however after downloading them and going to index.html, the webpage is stuck on loading or pure blank on at least 7 games i have tried, any help would be really appreciated i have no idea why this is or what to do

--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Aaron McLeod
http://agmprojects.com

Jay Oster

unread,
Mar 9, 2014, 1:32:58 PM3/9/14
to mel...@googlegroups.com
Or better yet: link us to the game hosted somewhere, like github (ideal), dropbox (can be setup as a webpage), a personal http server, etc.

David Henebery

unread,
Mar 15, 2014, 2:04:15 PM3/15/14
to mel...@googlegroups.com

ok so this is the only JS file i could find, its for https://github.com/tiagojsalmeida/Bitzz it reads:/**
 * Bitzz - The Game
 * Created by Tiago Almeida, 2011/2012
 */


function getCookie(c_name) {
    /*
     Get value from a cookie:
     */
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}

var initialLevel = getCookie("level_id"),
    level_time = getCookie("level_time"),
    checkpoint_cookie,
    url = window.location.search,
    url_split = url.split("?"),
    sound = url_split[1],
    color = url_split[2];

if (initialLevel == undefined || initialLevel == null || initialLevel == "") {
    initialLevel = url_split[3];
    level_time = url_split[4];
}
var lvl_id = new Array();

for (var ii = 0; ii <= 14; ii++) {
    lvl_id[ii] = url_split[6 + ii]
}
var highscore = "false",
    highscore2 = "false",
    time_end = "0",
    swCycleTime = 50,
    swcount = 0,
    sw,
    swObj,
    swct,
    swnow,
    swcycle,
    swObjAry = new Array();

function goHome() {
    var general = "?" + highscore + "?" + highscore2 + "?" + time_end + str_url + "?" + lvl_id.join("?");
    document.cookie = 'general=' + general + '; expires=Thu, 2 Aug 2055 20:47:11 UTC; path=/';
    document.location = "index.html" + general;
}

function swStart(id, ud) {
    swObj = document.getElementById(id);
    swct = swObj.value.split(':');
    swnow = new Date();
    swObj.now = swnow.getTime();
    swObj.reset = level_time;
    if (swcount == 0) {
        swObj.value = level_time;
    }
    swcount++;
    swObj.ud = ud;
    if (!isNaN(swObj.value)) {
        swObj.time = parseInt(swObj.value);
    } else if (swct.length == 4) {
        swObj.time = (swct[0] * 1000 * 60 * 60) + (swct[1] * 1000 * 60) + (swct[2] * 1000) + parseInt(swct[3]);
    } else if (swct.length == 3) {
        swObj.time = (swct[0] * 1000 * 60) + (swct[1] * 1000) + parseInt(swct[2]);
    } else if (swct.length == 2) {
        swObj.time = (swct[0] * 1000) + parseInt(swct[1]);
    } else if (swct.length == 1) {
        swObj.time = parseInt(swct[1]);
    }
    if (!swObj.time) {
        swObj.time = 1;
    }
    if (!swObj.c) {
        swObj.c = ud;
        swObjAry[swObjAry.length] = swObj;
    }
}

function swStop(id) {
    swObj = document.getElementById(id);
    if (!swObj.time) {
        return;
    }
    swObj.time = null;
    sw = new Date().getTime();
    swObj.cycle += (sw - swcycle);
    if (swObj.ud == '-') {
        swObj.cycle -= (sw - swcycle);
        if (swObj.cycle < 0) {
            swObj.cycle = 0;
        }
    }
    swObj.value = (parseInt(swObj.cycle / 1000 / 60 / 60) % 24) + ':' + (parseInt(swObj.cycle / 1000 / 60) % 60) + ':' + ((parseInt((swObj.cycle) / 1000) % 60) + ':' + (swObj.cycle % 1000));
}

function swCycle() {
    swcycle = new Date().getTime();
    for (sw0 = 0; sw0 < swObjAry.length; sw0++) {
        if (swObjAry[sw0].time) {
            swObjAry[sw0].cycle = swObjAry[sw0].time + (swcycle - swObjAry[sw0].now);
            if (swObjAry[sw0].ud == '-') {
                swObjAry[sw0].cycle = swObjAry[sw0].time - (swcycle - swObjAry[sw0].now);
                if (swObjAry[sw0].cycle < 0) {
                    swObjAry[sw0].cycle = 0;
                    swObjAry[sw0].time = 0;
                }
            }
            swObjAry[sw0].value = (parseInt(swObjAry[sw0].cycle / 1000 / 60 / 60) % 24) + ':' + (parseInt(swObjAry[sw0].cycle / 1000 / 60) % 60) + ':' + ((parseInt((swObjAry[sw0].cycle) / 1000) % 60) + ':' + (swObjAry[sw0].cycle % 1000));
        }
    }
}

function swReset(id) {
    swObj = document.getElementById(id);
    swObj.value = swObj.reset;
    swObj.time = null;
}

setInterval('swCycle()', swCycleTime); " 

Sorry for the late reply and sorry for not posting an example, that was pretty stupid, heres a picture of the screen i get http://imgur.com/g3uVa3i  the intro runs but never the game, thanks for the reply

Jay Oster

unread,
Mar 16, 2014, 2:31:51 AM3/16/14
to mel...@googlegroups.com
Hi David. You can't run the games from `file://` URIs, because browsers have very strict access restrictions to files loaded this way (the art and sound assets will not work when loaded this way, with default browser settings).

You can either start Chrome with a special command line flag to allow local file privileges (not really recommended) or host the game on an HTTP server like nginx (recommended!), lighttpd, or cherokee.

David Henebery

unread,
Mar 16, 2014, 11:34:31 AM3/16/14
to mel...@googlegroups.com

Hi thanks so far for the response and help, last thing, the tutorials were kind of iffy on how exactly to do the "--allow-file-access-from-files" and im a giant scrub so i finally got to what the articles were saying to do, but it hasnt seem to have worked, heres a screeny, i know i screwed something up..http://imgur.com/aYmJhmE sorry in advance :s

Jay Oster

unread,
Mar 16, 2014, 3:17:55 PM3/16/14
to mel...@googlegroups.com
That looks correct. Next, you should open the Chrome developer console (Ctrl+Shift+J) and look for any error messages.

David Henebery

unread,
Mar 17, 2014, 1:00:12 PM3/17/14
to mel...@googlegroups.com
Well heres the errors it says http://i.imgur.com/g0g5JFR.png but i can just drop it if you want i've already used a lot of time

Aaron McLeod

unread,
Mar 17, 2014, 1:10:42 PM3/17/14
to mel...@googlegroups.com
You might just be better off installing something like apache or installing python and using its simple http server: http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python rather than wrestling with passing  various flags. The problem there is it's trying to load a js file, and that hasn't been allowed either. So you see the html file, but it's not loading impact. By the way if you're using impact instead of melon, you might want to ask them on their forums :). Impact JS's level editor requires PHP to run, so you will need a WAMP (Apache + MyQL + PHP) install or something of the sort to run it.


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Oster

unread,
Mar 17, 2014, 1:29:06 PM3/17/14
to mel...@googlegroups.com
The game shown in the last screen shot is using Impact, which is a different game engine (not melonJS). Impact is not really our area of expertise. :) You might be able to receive help for that on the Impact forum: http://impactjs.com/forums/

David Henebery

unread,
Mar 19, 2014, 4:33:15 PM3/19/14
to mel...@googlegroups.com
yea sorry i realised it was a different game engine a couple posts back but i was getting identical results with melonjs so didnt wanna overcomplicate, well thanks for the help anyway

David Henebery

unread,
Mar 19, 2014, 4:54:14 PM3/19/14
to mel...@googlegroups.com
ok so i found a game which is definitely melonjs https://github.com/melonjs/melonJS/tree/master/examples/whack-a-mole    but when i go to play it this error appears in the developer console

:Failed to load resource: net::ERR_FILE_NOT_FOUND
Uncaught ReferenceError: me is not defined debugPanel.js:20
Uncaught ReferenceError: me is not defined entities.js:5
Uncaught ReferenceError: me is not defined HUD.js:10
Uncaught ReferenceError: me is not defined play.js:1
Uncaught TypeError: Object [object global] has no method 'onReady' index.html:28

Jay Oster

unread,
Mar 19, 2014, 9:01:43 PM3/19/14
to mel...@googlegroups.com
How did you download the whack-a-mole example? 

The melonJS source code repository is structured so that the examples all use the same melonJS library from the build directory. Unless you have the entire repository *and* built melonJS, the examples will not work.

You can get the example(s) with pre-built melonJS library from the examples repo: https://github.com/melonjs/examples

Aaron McLeod

unread,
Mar 19, 2014, 9:04:06 PM3/19/14
to mel...@googlegroups.com
Also there's the issue of not running it on a webserver :)
Reply all
Reply to author
Forward
0 new messages