and loaded 4 images in editor as iconGui
then i have this line
this.icbag=this.iconGui[0]…and also tried to add .resource…but don’t seems right
in previous scripts i had this
Yes it’s totally a raphael issue with new scripts, i will restart the project switching back to old scripts since seems there is no documentation about raphael with playcanvas.
I stress that you should use the debugger in the browser more to help figure what is going on when you hit problems like this. Using callstack and breakpoints helped me to identify that you were passing in undefined variables to the Raphael function in GUI.js.
Uhm i see…in the previous version of script it worked fine putting it before the initialize function, so no i need to put that inside the initialize function…i see…since debugger didn’t show me the problem but just pointed out raphael script i thought it was a problem of raphael…now i see is just my lacking of knowledge. Thanks a lot @steven
The crash was in Raphael, but if you use the un-minified version of script, you can check over the code and have a quick look at the data that is being used at that time.
So on the line before it crashes in Raphael, you can see two arguments being undefined:
Oh yes i see…didn’t thought of that…as i told i didn’t think to move the this,icoSheetWidth definition inside initialize…so didn’t come in my mind that the problem could be this…newbie mistake with the new scripts.[quote=“steven, post:9, topic:3343”]
Was the previous version of the script in the old script system?
[/quote]
pc.script.create('Level', function (app) {
// Creates a new Level instance
var Level = function (entity) {
this.entity = entity;
this.map = {};
this.freeCells = [];
//this.depth = 0;
this.walls = {};
this.visible = {};
this.traps = {};
};
Level.prototype = {
// Called once after all resources are loaded and before the first update
initialize: function () {
this.game = app.root.findByName('Root').script.Game;
this.player=app.root.findByName('Player').script.player;
this.output= app.root.findByName('Root').script.Output;
//this.calc=app.root.findByName('calc').script.maths;
this.createNewLevel();
},
The variables such as this.map, this.walls etc, they are within scope of the script instance of Level whereas the code you had in the new scripting system was in global scope and not the script instance.
In a nutshell, put all your script instance variables in the initialize function for the new scripting system.