Jump to content


Photo

Stuff works/doesn't work in html5


  • Please log in to reply
3 replies to this topic

#1 mysteriosum

mysteriosum

    GMC Member

  • GMC Member
  • 12 posts

Posted 18 September 2012 - 05:17 PM

So, I've been working on a game for a while now, and I've finally run into a confounding problem that, as far as I can tell, doesn't really have to do with my code... I have a very simple piece of code which:
a) works in Windows;
B) doesn't work when run normally in HTML5;
c) works fine in HTML5 Debug mode;
and d) seems to do impossible things.

This is code in a Step function for a Spawner I made:

myTimer += 1;

if (myTimer >= myRate){
    if (toSpawn){                  //if the object I'm going to spawn exists...
        if (instance_number(toSpawn) < 6){
            spawn = instance_create(x,y,toSpawn);
            spawn.targetX = nextTarget.x;
            spawn.targetY = nextTarget.y;
            spawn.onTrack = true;
        }
    }
    myTimer = 0;

    show_message("SPAWN!");
}

As it is, it spawns 6 guys right away, the first time myTimer's value reaches that of myRate (30). Even though I set myTimer down to 0 IN the If. If I change the first 'if' to
if (myTimer == myRate)
it will spawn exactly 1 guy, and never again any more ever, even if I destroy the one guy. So, it's doubly broken. Not to mention the fact that it won't show the show_message message ever. It seriously seems to be skipping over parts of my code, whenever it likes. Someone tell me what's going wrong, or at least if it's my fault? ;_;
  • 0

#2 mysteriosum

mysteriosum

    GMC Member

  • GMC Member
  • 12 posts

Posted 18 September 2012 - 06:09 PM

OK, so it turns out that there was something wrong with changing the variables of the spawned object. I took away 'targetX' and 'targetY' and 'onTrack' and now it works. Still, some way of alerting me in the browser would've been nice...
  • 0

#3 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16818 posts
  • Version:GM:Studio

Posted 18 September 2012 - 06:23 PM

Browsers have debug tools to help you and they are far better than anything GM could offer. So, if you run the game from GM in debug mode and then open up the console on Chrome or run Firebug on Firefox, you can see the errors and what's causing them.
  • 0

#4 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4880 posts
  • Version:GM:Studio

Posted 04 October 2012 - 01:18 AM

Debugging HTML5 games is extremely difficult in the current state. It's something you'll just have to get used to until YoYo add better support for it. Test constantly and make use of show_message() as a breakpoint system of sorts.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users