nio_kasgami Posted September 22, 2020 Share Posted September 22, 2020 Hi, I love a lots the implementation of Spritesheet since it work like atlas and for UI it's wonderful to use or any project who has a lots of Sprites. Although the way that MZ or rpg maker implements sprite seem to be a puzzle I can seem to figure out to implement Spritesheet. Here's the SPrite API source code : https://developer.rpgmakerweb.com/rpg-maker-mz/Sprite.js.html#line9 It seem to be working through Bitmap (which is common with RM) instance instead of a direct texture so figuring out how to implement it here's the Bitmap class API source code : https://developer.rpgmakerweb.com/rpg-maker-mz/Bitmap.js.html#line9 My guess was to go and Set the base texture / image to point towards the Spritesheet but I am unsure if it would not work? my guess would be also to create an instance of Spritesheet inside the bitmap class but it seem that would actually cause a memory leak (creating instance duplicates) so I am kinda at lost there? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 22, 2020 Share Posted September 22, 2020 (edited) put spritesheet baseTexture to bitmap sprite.bitmap = myBitmap sprite.texture = oneOfSpriteSheetTextures sprite._frame = oneOfSpriteSheetTextures.frame something like this should work Edited September 22, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
nio_kasgami Posted September 22, 2020 Author Share Posted September 22, 2020 @ivan.popelyshev Thanks! so if I understand MyBitmap is being the new Bitmap()? I am unsure (sorry if I am dumb) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 22, 2020 Share Posted September 22, 2020 I honestly didnt try it yet. In theory, if you put baseTexture into bitmap, this has to work. I thought that RM author will rewrite Bitmap when we added new functions in pixi-v5 specially for that, well, its not the case Quote Link to comment Share on other sites More sharing options...
nio_kasgami Posted September 22, 2020 Author Share Posted September 22, 2020 (edited) I see well that's the thing they didn't rewrite much and didn't inputed that. I will do some test so if I understand what u say the code should look like this : var spritesheet = SpriteSheet["MySprite"]; // Let's assume it was loaded before hand var sprite = new Sprite(); sprite.bitmap.basetexture = spritesheet.basetexture; sprite.texture = spritesheet.texture; sprite._frame = spritesheet.frame; I aint sure ill try to write an Atlas wrapper so it automatically setup those things. but yeah if I understand correctly it's how you would approach it? Edited September 22, 2020 by nio_kasgami Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 22, 2020 Share Posted September 22, 2020 "spritesheet.texture.frame" not "spritesheet.frame" Yes. I would do it and debug the result. In case you use trimming or rotations in spritesheet, try "texture.orig" instead of frame. nio_kasgami 1 Quote Link to comment Share on other sites More sharing options...
nio_kasgami Posted September 22, 2020 Author Share Posted September 22, 2020 okay okay ill test it tonight Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.