Okay, it just hit me, it should have been this.drawName(); so it was a Syntax error on my part, problem is no tutorial I read said how to use a method/function, only how to define it.
-------------------------
Just started out with JS and am a bit uncertain why the following code works, but my attempt at changing and modularising it lead to some problems. First the original:
-------------------------
Just started out with JS and am a bit uncertain why the following code works, but my attempt at changing and modularising it lead to some problems. First the original:
I wanted to change it so that all my sprites are added in their own sub-methods, or in this case functions:Scene_Title.prototype.drawGameTitle = function() {
// Background
var bitmap = ImageManager.loadTitle1('TitleBG');
var bg = new Sprite(bitmap);
this._bg = bg;
this.addChild(bg);
...
// Title Name
var bitmap = ImageManager.loadTitle1('TitleName');
var titleName = new Sprite(bitmap);
this._titleName = titleName;
this._bg.addChild(titleName);
}
Appearently this._bg is undefined in the new function, so what am I doing wrong? Is it a simple Syntax error or have I missed something deeper? (I am most familiar with Ruby where this kind of thing should have worked)...
// Title Name
Scene_Title.prototype.drawName();
}
Scene_Title.prototype.drawName = function() {
var bitmap = ImageManager.loadTitle1('TitleName');
var titleName = new Sprite(bitmap);
this._titleName = titleName;
this._bg.addChild(titleName);
}
Last edited:

