Hi people!
I was making a plugin that creates a bitmap on the screen.
But I'm having some problems getting the width and height of that.
I have a function that receives arguments that help put the bitmap in a predefined position on the screen through his width and height.
when I create the bitmap, it does not give me his width and height, in the function "setPosition"
But if I put the function "setPosition" to be called on the update, it will give me the width and height, but only after the first update. Because in the first, it will always give me 0 for both sizes.
This sprite is created in Scene_Title. Perhaps I should set the X and Y position on the function from the Scene_Title that I'm using to create the sprite?
I was making a plugin that creates a bitmap on the screen.
But I'm having some problems getting the width and height of that.
I have a function that receives arguments that help put the bitmap in a predefined position on the screen through his width and height.
when I create the bitmap, it does not give me his width and height, in the function "setPosition"
JavaScript:
Sprite_PressStart.prototype.initialize = function() {
Sprite_Base.prototype.initialize.call(this);
this.createBitmap();
this.setPositions();
};
Sprite_PressStart.prototype.createBitmap = function(){
const image = ImageManager.loadSystem(Eli.PressStart.Param.image);
this.bitmap = image;
console.log(this.bitmap.width) // returns 0
console.log(this.bitmap.height) // returns 0
};
Sprite_PressStart.prototype.setPositions = function(){
const param = Eli.PressStart.Param;
const position = Eli.Book.presetPos(this.bitmap.width, this.bitmap.height, param.customX, param.customY, param.preset);
this.move(position.x, position.y);
};
Sprite_PressStart.prototype.update = function(){
//this.setPositions(); If I put it here, everything works fine and I can get the sizes of the bitmap.
// More code here...
};
This sprite is created in Scene_Title. Perhaps I should set the X and Y position on the function from the Scene_Title that I'm using to create the sprite?

