Item Pop-up Notification Help?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
HypersDev
Newbie
Posts: 18
Joined: Thu Jul 16, 2020 1:43 am
Projects: DutyCalls
itch: ItsHypers
Contact:

Item Pop-up Notification Help?

#1 Post by HypersDev »

Hello!

I have a mini-game where you click on an object, and it adds it to your inventory. Although I want to add a feature where, when you click on the object, it plays a little animations next to the object, (a little +1) using a webm file, or something similar, although I can't figure out how to do it, as I cant figure out how to add a timer, add a transform / location of the file etc. Has anyone done anything like this before?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Item Pop-up Notification Help?

#2 Post by Alex »

The solution depends of how you show objects for mini-game and how you arrange player's interaction with the game. If you'll provide the code you got, this definetly will help to suggest something more accurate.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Item Pop-up Notification Help?

#3 Post by hell_oh_world »

You can try triggering a variable when the object is added to the inventory.

Code: Select all

image item add = Movie(...)
define item_add_dur = 0.25

screen test():
  default item_added = False
  
  textbutton "add" action [SetScreenVariable("item_added", True), ...]
  
  if item_added:
    add "item add" # show the anim...
    timer item_add_dur:
      action SetScreenVariable("item_added", False)
      
https://www.renpy.org/doc/html/movie.ht ... ie-sprites
Last edited by hell_oh_world on Fri Aug 20, 2021 1:30 pm, edited 1 time in total.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Item Pop-up Notification Help?

#4 Post by rayminator »

create a new screen called screen got_a_new_item():

this is a easy way of doing it:

Code: Select all

screen got_a_new_item():

    hbox:
        yalign 0.5
        xalign 0.5
        text "You got a new item"
and then anywhere in your game inside a label

Code: Select all

label f:
    e "Hello I wnat to buy this item"
    a "Okay, here you go, that will be $19.95"
    $ item += 1
    show screen got_a_new_item
    pause 0.5
    hide screen got_a_new_item
    e "Thank you."
    a "Please come again..."

User avatar
emz911
Regular
Posts: 103
Joined: Fri Jun 23, 2017 2:23 pm
Contact:

Re: Item Pop-up Notification Help?

#5 Post by emz911 »

Just to add to the other answers, you can use a timer with an action Hide("yourscreen") in the screen so that you won't have to copy and paste the pause and hide screen lines every time you show the screen. See: https://www.renpy.org/doc/html/screens.html#timer

User avatar
HypersDev
Newbie
Posts: 18
Joined: Thu Jul 16, 2020 1:43 am
Projects: DutyCalls
itch: ItsHypers
Contact:

Re: Item Pop-up Notification Help?

#6 Post by HypersDev »

Alex wrote: Fri Aug 20, 2021 1:22 pm The solution depends of how you show objects for mini-game and how you arrange player's interaction with the game. If you'll provide the code you got, this definetly will help to suggest something more accurate.
Sure thing!

The mini-game in question is this one:
viewtopic.php?f=51&t=62952&p=545724#p545724

I want to make it so, once you click a fruit, it visibly shows a +1 fruit icon next to the fruit like a little pop-up.

User avatar
HypersDev
Newbie
Posts: 18
Joined: Thu Jul 16, 2020 1:43 am
Projects: DutyCalls
itch: ItsHypers
Contact:

Re: Item Pop-up Notification Help?

#7 Post by HypersDev »

rayminator wrote: Fri Aug 20, 2021 1:28 pm create a new screen called screen got_a_new_item():

this is a easy way of doing it:

Code: Select all

screen got_a_new_item():

    hbox:
        yalign 0.5
        xalign 0.5
        text "You got a new item"
and then anywhere in your game inside a label

Code: Select all

label f:
    e "Hello I wnat to buy this item"
    a "Okay, here you go, that will be $19.95"
    $ item += 1
    show screen got_a_new_item
    pause 0.5
    hide screen got_a_new_item
    e "Thank you."
    a "Please come again..."
How would I get this working with an animated image though? Can you use those in hboxs?

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Item Pop-up Notification Help?

#8 Post by rayminator »

HypersDev wrote: Tue Aug 24, 2021 4:33 pm
rayminator wrote: Fri Aug 20, 2021 1:28 pm create a new screen called screen got_a_new_item():

this is a easy way of doing it:

Code: Select all

screen got_a_new_item():

    hbox:
        yalign 0.5
        xalign 0.5
        text "You got a new item"
and then anywhere in your game inside a label

Code: Select all

label f:
    e "Hello I wnat to buy this item"
    a "Okay, here you go, that will be $19.95"
    $ item += 1
    show screen got_a_new_item
    pause 0.5
    hide screen got_a_new_item
    e "Thank you."
    a "Please come again..."
How would I get this working with an animated image though? Can you use those in hboxs?
all you have to do is make the animation into a video webp

Code: Select all

screen got_a_new_item():

    hbox:
        yalign 0.5
        xalign 0.5
        add "anim/your_video.webp"
        text "You got a new item"

or this way but I never tested it so it might not work

Code: Select all

image anim:
    "images/dark/dark9.png"
    pause 0.1
    "images/dark/dark8.png"
    pause 0.1
    "images/dark/dark7.png"
    pause 0.1
    "images/dark/dark6.png"

Code: Select all

screen got_a_new_item():

    hbox:
        yalign 0.5
        xalign 0.5
        add anim
        text "You got a new item"

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Item Pop-up Notification Help?

#9 Post by Alex »

HypersDev wrote: Tue Aug 24, 2021 4:32 pm
Alex wrote: Fri Aug 20, 2021 1:22 pm The solution depends of how you show objects for mini-game and how you arrange player's interaction with the game. If you'll provide the code you got, this definetly will help to suggest something more accurate.
Sure thing!

The mini-game in question is this one:
viewtopic.php?f=51&t=62952&p=545724#p545724

I want to make it so, once you click a fruit, it visibly shows a +1 fruit icon next to the fruit like a little pop-up.
Well, you can make it like

Code: Select all

screen fruit_event:
    $ Peachx = [275, 1431, 867, 617, 993]
    $ Peachy = [294, 244, 108, 315, 297]
    $ MushroomX = [443, 90, 1595, 675, 1308]
    $ MushroomY = [949, 933, 775, 658, 594]
    for i in range(maxint):
        imagebutton: #(925, 961)
            xanchor 0.5
            yanchor 0.5
            xpos 925
            ypos 961
            idle "gui/misc/fruit_event_done.png"
            hover "gui/misc/fruit_event_done_hover.png"
            action [Jump("FruitText")]
            unhovered Hide("displayTextScreen")
        if fruit_bools[i] == False:
            if chance_random[i] == 1 or chance_random[i] == 2 or chance_random[i] == 3 or chance_random[i] == 4 or chance_random[i] == 5:
                # Make peach
                # code code code
            if chance_random[i] == 6 or chance_random[i] == 7 or chance_random[i] == 8 or chance_random[i] == 9 or chance_random[i] == 10:
                # Make mushroom
                #code  code code

                        
        else: # <---
            add "plus_one" at plus_transform: # add your image, transform is optional,
                # positional properties are required
                xanchor 0.5
                yanchor 0.5
                if chance_random[i] == 1 or chance_random[i] == 2 or chance_random[i] == 3 or chance_random[i] == 4 or chance_random[i] == 5:
                    xpos Peachx[i]
                    ypos Peachy[i]
                if chance_random[i] == 6 or chance_random[i] == 7 or chance_random[i] == 8 or chance_random[i] == 9 or chance_random[i] == 10:
                    xpos MushroomX[i]
                    ypos MushroomY[i]
            
transform plus_transform:
    alpha 0.0 yoffset 0
    linear 0.5 alpha 1.0 yoffset -25
    linear 0.5 alpha 0.0 yoffset -25
    
# this might be text or static image or animated image or a movie-sprite
image plus_one:
    Text("+ 1", color="#c00", size=55)
https://www.renpy.org/doc/html/atl.html

Post Reply

Who is online

Users browsing this forum: No registered users