jjwallace Posted April 19, 2017 Share Posted April 19, 2017 var Fish = function (game, superThis, index, x, y, size, angle, pSize) { //Bunch of code console.log('FISHSIZE 1: ' + pSize); this.pSize = pSize; this.setSize(this.pSize); } Fish.prototype.constructor = Fish; Fish.prototype.setSize = function(pSize){ console.log('FISHSIZE 2: ' + pSize); } FISHSIZE 1: 0. 2 FISHSIZE 2: undefined Link to comment Share on other sites More sharing options...
rblopes Posted April 19, 2017 Share Posted April 19, 2017 Not sure if you've omitted this part of the code, but you're not assigning `pSize` to your prototype. this.pSize = pSize; // ... this.setSize(this.pSize); Link to comment Share on other sites More sharing options...
jjwallace Posted April 19, 2017 Author Share Posted April 19, 2017 oh sorry yah im doing that also but its not working, code updated Link to comment Share on other sites More sharing options...
jjwallace Posted April 19, 2017 Author Share Posted April 19, 2017 this.setSize(pSize) and this.pSize = pSize; this.setSize(this.pSize) Both dont pass scope Link to comment Share on other sites More sharing options...
rblopes Posted April 19, 2017 Share Posted April 19, 2017 Your code seems to be fine for me... Maybe too many params? Link to comment Share on other sites More sharing options...
jjwallace Posted April 19, 2017 Author Share Posted April 19, 2017 Weird cause its not working in my build. What would be too many params? Link to comment Share on other sites More sharing options...
rblopes Posted April 19, 2017 Share Posted April 19, 2017 Oh, sorry. What I meant by 'too many params' is that, in that code snippet you posted, you have 8 parameters in your `Fish` constructor (`pSize` is the last one). Maybe you're omitting it or not passing those parameters in the expected order. Link to comment Share on other sites More sharing options...
jjwallace Posted April 19, 2017 Author Share Posted April 19, 2017 Just checked and everything seems fine, fishconstructor received pSize but did not pass it to the funciton Link to comment Share on other sites More sharing options...
jjwallace Posted April 19, 2017 Author Share Posted April 19, 2017 You were right! I was forgetting a parameter in the call , thanks dude! Link to comment Share on other sites More sharing options...
Recommended Posts