Hey all,
I'm beginning to learn JS, and I'm doing alright but I've hit a snag I can't explain. I was following SRDude's tutorial on making a custom menu, and I went off the beaten track a bit and decided I wanted to add my own custom text box image. I was successful in getting it added, but I can't center it! I tried the recommended;
this._menuSprite.scale.x = Number(Graphics.width / this._menuSprite.width);
But it doesn't seem to have any value for width. I tried graphics.width / graphics.width and it returned the scale of 1 so I know that value is working, but it doesn't draw at all as soon as I try and use its width to create an accurate scale.
Any ideas on what might be causing this and how it might be fixed? I tried googling around, I can't find any good resources online for how to handle spites in JS. Am I missing a search term or a reference sheet or something that might help me find the answer myself? I also tried to use the console log, I couldn't get any sort of return on the sprite at all.
Thanks in advance!
I'm beginning to learn JS, and I'm doing alright but I've hit a snag I can't explain. I was following SRDude's tutorial on making a custom menu, and I went off the beaten track a bit and decided I wanted to add my own custom text box image. I was successful in getting it added, but I can't center it! I tried the recommended;
this._menuSprite.scale.x = Number(Graphics.width / this._menuSprite.width);
But it doesn't seem to have any value for width. I tried graphics.width / graphics.width and it returned the scale of 1 so I know that value is working, but it doesn't draw at all as soon as I try and use its width to create an accurate scale.
Any ideas on what might be causing this and how it might be fixed? I tried googling around, I can't find any good resources online for how to handle spites in JS. Am I missing a search term or a reference sheet or something that might help me find the answer myself? I also tried to use the console log, I couldn't get any sort of return on the sprite at all.
Thanks in advance!
(function() {
var background = String(PluginManager.parameters("AltMenuTest")['BackgroundPicture']);
var opacity = Number(PluginManager.parameters("AltMenuTest")['Window Opacity']);
var _Scene_MenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function() {
if(background) {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadPicture(background);
this.addChild(this._backgroundSprite);
this._menuSprite = new Sprite();
this._menuSprite.bitmap = ImageManager.loadPicture("Textbox1");
/*this._menuSprite.scale.x = 2.62;
this._menuSprite.scale.y = 0.6;*/
this.addChild(this._menuSprite);
this._menuSprite.scale.x = Number(Graphics.width / Graphics.width);
this._menuSprite.scale.y = 0.6;
}
else {
_Scene_MenuBase_createBackground.call(this);
}
};
var _Scene_Menu_create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function(){
_Scene_Menu_create.call(this);
var background = String(PluginManager.parameters("AltMenuTest")['BackgroundPicture']);
var opacity = Number(PluginManager.parameters("AltMenuTest")['Window Opacity']);
var _Scene_MenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function() {
if(background) {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadPicture(background);
this.addChild(this._backgroundSprite);
this._menuSprite = new Sprite();
this._menuSprite.bitmap = ImageManager.loadPicture("Textbox1");
/*this._menuSprite.scale.x = 2.62;
this._menuSprite.scale.y = 0.6;*/
this.addChild(this._menuSprite);
this._menuSprite.scale.x = Number(Graphics.width / Graphics.width);
this._menuSprite.scale.y = 0.6;
}
else {
_Scene_MenuBase_createBackground.call(this);
}
};
var _Scene_Menu_create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function(){
_Scene_Menu_create.call(this);