Reload on death doesn't work on html5?

argyxgames

  • Posts: 14
Hello,
I have the following code implemented, to have the game reload when the actor dies.
It works perfectly with flash, but not with html5: any idea?
Thanks!

yoplalala

  • *
  • Posts: 1467
I don't know if it's this . But I would remove the "kill self".
If the  actor is dead, how could  the block after still play ?

What's the problem in html5. It kills the actor but doesn't reload or is it something else ?

argyxgames

  • Posts: 14
Well it does work perfectly in flash.

And I just realized that it's not just that script: even the other basic scripts that reload the scene when an actor falls ('Die in Pit and Reload'), or goes out of the screen, do not work with HTML5: the actor is killed, the scene reloads but the screen is black and there are no controls anymore (although in Flash it reloads properly).

Edit: same thing happens if I just remove "kill self"

« Last Edit: August 07, 2018, 06:17:00 am by argyxgames »

merrak

  • *
  • Posts: 2092
Do any errors appear in the log viewer?

argyxgames

  • Posts: 14
Do any errors appear in the log viewer?

Yes, some files are missing:
ios-sim.exe
tail.exe
cc1plus.exe
arm-linux-androideabi-g++.exe
adb.exe
neko.exe

argyxgames

  • Posts: 14
I've read this thread: http://community.stencyl.com/index.php/topic,47294.0.html and updated Visual Studio with the C++ components, but problem remains the same  :-\

colburt187

  • *
  • Posts: 2244
do you have a save block when the screen reloads? try removing any save blocks as a test to see if it still happens.

argyxgames

  • Posts: 14
do you have a save block when the screen reloads? try removing any save blocks as a test to see if it still happens.
No save block at all.

argyxgames

  • Posts: 14
You can check out the problem directly with the online html5 version of the first level:
http://www.argyxgames.com/apocalypse/prelude/sigillum/

merrak

  • *
  • Posts: 2092
If you're on Chrome you can pull up the debug console with ctrl+shift+j. This appears when a scene loads:

Code: [Select]
Uncaught J {val: "Cannot cast null to {↵ __name__ : [com,stencyl,models,actor,ActorType]↵}", message: "Cannot cast null to {↵ __name__ : [com,stencyl,models,actor,ActorType]↵}", stack: "Error: Cannot cast null to {↵ __name__ : [com,sten…/apocalypse/prelude/sigillum/Sigillum.js:588:493)"}

There are a number of reasons why code might work on one platform and not another. One reason is that some platforms are more "forgiving" of certain errors, which is likely the case here.

I looked at line 588 but it's not very useful to me. Would be helpful to know what .hx file generated that part of the code. You can see the generated code here: http://www.argyxgames.com/apocalypse/prelude/sigillum/Sigillum.js

So something is definitely wrong... looks like with an actor or actor type.

Edit. The error appears when the scene first loads, and a second time when the scene reloads. So the problem is when the scene begins, not the code that reloads it when the character dies.

« Last Edit: August 08, 2018, 07:48:54 am by merrak »

argyxgames

  • Posts: 14
I'm not entirely sure what caused the bug, but I removed all the added behaviors on Actors (that were not actually used, but still saved along with the game) and now it seems it works fine!

Thanks for helping out!

merrak

  • *
  • Posts: 2092
My hunch is that one of them had some kind of null value that prevented the scene from working properly. The annoying thing about working with different platforms is that there's not a consistency in how they handle uninitialized variables. Unfortunately I don't think there's anything Stencyl can do about that. It's the nature of working with multiple platforms.

This is something to keep in mind if you use 'value of game attribute with name ###' blocks. If you try to access a game attribute you've never set before, sometimes it's assumed to be zero--sometimes it's null. (If you make game attributes using the settings menu then you won't have this problem, since you're forced to specify if it's a string, number, etc.)

If you run into this problem again, one thing you can do is comb through your behaviors and make sure all the attributes have an initial value. Most of the time when you set up an attribute you have to specify an initial value--but some, like actors, fonts, or lists, can be null.

The other thing to try is compiling to desktop. Desktop code (CPP) is more rigorous and is likely to crash where Flash or HTML5 might try to keep going with now "poisoned" code... like what happened in your game. You have a better chance of finding the actual error if the program crashes immediately when the problem occurs.

argyxgames

  • Posts: 14
The other thing to try is compiling to desktop. Desktop code (CPP) is more rigorous and is likely to crash where Flash or HTML5 might try to keep going with now "poisoned" code... like what happened in your game. You have a better chance of finding the actual error if the program crashes immediately when the problem occurs.
Absolutely right, I'll bear that in mind! Thanks.