valueerror Posted April 10, 2015 Share Posted April 10, 2015 in my newest game i'm having serious troubles .. it's the first time that i have absolutely no clue why things happen the way they happen the biggest problem is that the game works as expected but after 3 to 10 minutes things suddenly happen that should not happen.. i did not program those things.. i went over my code a hundred times now my sprites that are constantly killed and reset suddenly are killed right after the reset.. but the reset sets a custom object variable to true and therefore should block the killing (but it doesn't) it's no complex thing.. if (var == true) {do not kill !!!!!!} (but it's killed anyway) this is probably related to what i just observed. i wrote the following code in my kill function in order to find out more about those weird problems: if (obj.sprite.onAir === true){console.log(obj.sprite); return;}the interesting thing is that if i look at chromes console log the sprite definitely says " onAir = false " if it really were false it shouldn't be in the log .. right ??? what the hell? (using phaser 2.3) Link to comment Share on other sites More sharing options...
qdrj Posted April 10, 2015 Share Posted April 10, 2015 Make setter for onAir variable and put debug breakpoint there so you will be able to check what caused change of this var. ZoomBox 1 Link to comment Share on other sites More sharing options...
valueerror Posted April 10, 2015 Author Share Posted April 10, 2015 thx for your reply do you think that something changed the value right between the if statement and the console.log() ?? i'm definitely going to investigate that..... there are only 2 places where i set onAir to true.. the "exploding" function that sets onAir to true but sets it back to false after a tween and right before it calls the kill function(so objects passed to the kill function from here should never be "onAir" ) an the reset function which is called every second ... so this one falls out of the "linear" concept.. it suddenly kicks in and could interfere in very VERY rare cases.. im going over my "reset function" again.. there has to be a logical reason for that .. Link to comment Share on other sites More sharing options...
ZoomBox Posted April 10, 2015 Share Posted April 10, 2015 I ever had this kind of problem with console.log(object). That's definitly what qdrj said. If you're loggin an object, then when you go through its parameters, the values are the CURRENT ones of the object, not the ones that were set when you logged it. To be clear:player.alive = true;console.log(player);player.alive = false; => Check in console: player.alive is false. I don't know if it's browser related but now I use "debugger;" or breakpoint. Link to comment Share on other sites More sharing options...
valueerror Posted April 11, 2015 Author Share Posted April 11, 2015 thank you both.. after inspecting the reset function that is called every second i found a way how this could interfere with the kill function i wrote and removed that rare case.. the game is now running properly and the weird behaviour is gone.. only one problem left though.. the game is getting slower over time.. but this is a topic for a different thread Link to comment Share on other sites More sharing options...
Recommended Posts