netgfx / phaser_modals

Phaser.io Modals creator script
MIT License
60 stars 18 forks source link

element frame not working/how to update exactly? #12

Closed vitorregisrr closed 6 years ago

vitorregisrr commented 6 years ago

Hey guys! Why isnt my spritesheet frame working? i'm using in the code below but no results.. { type: "image", content: "starsSpritesheet", frame: 2, offsetY: 15, offsetX: 0, },

i have other question, i didnt underestand the function, for update it i need to use the updateModalValue right? Should i use like this: updateModalValue('gameSucessModal', 2/<-the frame number/, 5 /the position of the element into the array??/); ? reg.modal.createModal({ type: "gameSucessModal", includeBackground: false, modalCloseOnInput: false, itemsArr: [{ type: "image", content: "levelSuccess", offsetY: -20, contentScale: 1 }, { type: "text", content: "0", fontSize: 25, fontFamily: "Komika", color: "#fffff", offsetY: -45, offsetX: -60, }, { type: "text", content: "0", fontSize: 25, fontFamily: "Komika", color: "#FFFF", offsetY: -45, offsetX: 60, }, { type: "image", content: "btnRestart", offsetY: 100, offsetX: 0, callback: function () { game.paused = false; game.state.start("gameState"+(levelNumber)); } }, { type: "image", content: "btnLeft", offsetY: 85, offsetX: -80, callback: function () { game.paused = false; game.state.start("levelState"); } }, { type: "image", content: "starsSpritesheet", frame: 2, offsetY: 15, offsetX: 0, }, { type: "image", content: "btnRight", offsetY: 85, offsetX: 80, callback: function () { game.paused = false; game.state.start("gameState"+(levelNumber +1)); } } ] });

netgfx commented 6 years ago

For using a spritesheet (a jsonAtlas specifically like this: https://phaser.io/examples/v2/loader/load-texture-atlas) use the { type: "sprite", atlastParent: "nameOfAtlasKey", content: "theFrameName"} to use updateModalValue you need to provide it with the following:

vitorregisrr commented 6 years ago

cant i use a spritesheet without atlas? justing calling the frame number? and as the updateModalValue can be used just for change texts,images and bitmapTexts there isnt any way to change a sprite frame? should i use different images and change de texture?

netgfx commented 6 years ago

Yes you can use an image and change texture.

No unfortunately the library doesn't support changing a frame from a sprite not even with atlas (but it supports creating a modal with atlas)

Feel free to do a pull request and implement this your self, I can provide guidance, but I don't have the time to update the lib right now.

vitorregisrr commented 6 years ago

I made the changes in LIB, now you can add sprites without atlas and change the frame with the option frame and also update it with the update function.