Page 1 of 1

[Solved] SetVariable + animated image?

Posted: Sun May 12, 2019 5:02 pm
by nanashine
I'm using a code like this to allow the player to choose some images like icons, etc.

Code: Select all

default iconjhon = '1'
image iconjhon:
        "icons/icon[iconjhon].png"
        pos (70,200)  
        

screen chooseiconjhon:

    textbutton '{size=30} Avatar{/size}' action SetVariable('iconjhon', '1'), Return() pos(50,240)

    textbutton '{size=30} Avatar{/size}' action SetVariable('iconjhon', '2'), Return() pos(215,240)
There's a part of my game where you receive a gift. This gift is an animated image. It will appear as a decoration item in a few scenes.
The problem is that this image will change according to which character your chose as your pair. For eg, if you chose Jhon it will be flowers. If you chose Adam it will be a cat, etc. But depending on which choice you make, you won't receive a gift hahah

So:

Code: Select all

screen receicedgift:
    add "gift"
    
label yourlivingroom12:
    
    scene livingroom
    show screen receicedgift
If you don't win any gift, the image "gift" keeps being an empty image (a transparent png).
If you win the flowers, "gift" should show the animated image of flowers.
If you win the cat, it would be the animated image of a cat.

The problem is that since the image is animated, I don't know how to use "SetVariable" to do that.
If the gift were a static image, I'd simply do it like the example above.

Like, if you chose Jhon, then I'd add a textbutton saying "you receive flowers from Jhon" with the action "SetVariable('gift', '1')", something like that.

Does anyone know how I can do it?

Thanks.

Re: SetVariable + animated image?

Posted: Mon May 13, 2019 8:38 am
by Nagibator
Probably not the answer you're looking for, but I think you can use if statements to choose which textbutton will show based off of who you chose.

As for if you want the button to do something specific, you can create a function in your init python that will do exactly what you want. Then just make the button use that function with:
action Function(yourFunctionNameHere)

Again, if this doesn't help, my sincerest apologies. My mind is a little scattered currently, but felt like attempting to be helpful.

Re: SetVariable + animated image?

Posted: Mon May 13, 2019 12:56 pm
by nanashine
Nagibator wrote:
Mon May 13, 2019 8:38 am
Probably not the answer you're looking for, but I think you can use if statements to choose which textbutton will show based off of who you chose.

As for if you want the button to do something specific, you can create a function in your init python that will do exactly what you want. Then just make the button use that function with:
action Function(yourFunctionNameHere)

Again, if this doesn't help, my sincerest apologies. My mind is a little scattered currently, but felt like attempting to be helpful.
Thank you so much! I'll give it a try :)

Re: SetVariable + animated image?

Posted: Mon May 13, 2019 1:05 pm
by Nagibator
nanashine wrote:
Mon May 13, 2019 12:56 pm
Thank you so much! I'll give it a try :)
No problem. Wishing the best for you.

Re: SetVariable + animated image?

Posted: Mon May 13, 2019 1:52 pm
by nanashine
Nagibator wrote:
Mon May 13, 2019 1:05 pm
nanashine wrote:
Mon May 13, 2019 12:56 pm
Thank you so much! I'll give it a try :)
No problem. Wishing the best for you.
Thank you!
I made it work in a odd way, but worked hah

I created the animated image, then:

Code: Select all

screen wongift:
    
        textbutton '{size=30}Show gift{/size}' action SetVariable('gift', 'cat') pos(10,10)


screen receivedgift:
    add gift


default gift= "empty.png"
Image "gift" is a default empty image (empty.png). And the screen "receivedgift" is always there. If you won something, the action SetVariable('gift', 'cat') pos(10,10) will turn de default into the gift you won. 'cat' being the animated image.

Now I just have to adjust it to look cool, but it's working hahah

Thank you for your idea too.

Re: SetVariable + animated image?

Posted: Mon May 13, 2019 5:47 pm
by Nagibator
nanashine wrote:
Mon May 13, 2019 1:52 pm
Now I just have to adjust it to look cool, but it's working hahah

Thank you for your idea too.
Good to know. And you're welcome. :)