I'm trying to log the width of a picture in my script.
I have the setup below, where I use a script to show the picture.
I have a second script to get the width of the image.
Unless I put a wait command between the two scripts the width will be zero.
I know the wait allows time for the picture to load, which is why the width is returned.
I have concerns about using this approach, as the load time could be different depending on the device, and it feels a bit hacky.
Does any one know if I can replace the wait command with something that detects that the picture has loaded?
Script: $gameScreen.showPicture(1, "SF_PEOPLE1_8", 0, (Graphics.boxWidth),200, 100, 100, 255, 0)
Wait: 5 frames
Script: var picSpriteset = SceneManager._scene._spriteset.children.find(obj => obj.children.length >= 99);
console.log(picSpriteset.children[0].width);
I have the setup below, where I use a script to show the picture.
I have a second script to get the width of the image.
Unless I put a wait command between the two scripts the width will be zero.
I know the wait allows time for the picture to load, which is why the width is returned.
I have concerns about using this approach, as the load time could be different depending on the device, and it feels a bit hacky.
Does any one know if I can replace the wait command with something that detects that the picture has loaded?
Script: $gameScreen.showPicture(1, "SF_PEOPLE1_8", 0, (Graphics.boxWidth),200, 100, 100, 255, 0)
Wait: 5 frames
Script: var picSpriteset = SceneManager._scene._spriteset.children.find(obj => obj.children.length >= 99);
console.log(picSpriteset.children[0].width);