Place Items in the Backgrounds and hide after click

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
Darim
Regular
Posts: 67
Joined: Sun Jun 21, 2015 4:17 pm
Organization: Setsuna Ken
Github: SetsunaKen
Location: Germany
Contact:

Place Items in the Backgrounds and hide after click

#1 Post by Darim » Sat Jul 18, 2015 3:19 pm

Hey Guys,

I want to place items in my backgrounds.

So Basically I want to show images in the background and if you click on them the items should disappear/hide. You don't have to collect them so if you go ahead without to click on the Items nothing will happen.

Example:
If click on item1.jpg:
hide item1.jpg
$ secret_item +=1
"You have found Item1."
else
do nothing

Is there a easier way to do it without using imagemaps and hotspots ?

User avatar
sashaaero
Regular
Posts: 45
Joined: Mon Jul 13, 2015 6:08 pm
Projects: Everlasting Cold
Organization: OverDream Development
Github: sashaaero
Skype: sashaaero
Contact:

Re: Place Items in the Backgrounds and hide after click

#2 Post by sashaaero » Mon Jul 20, 2015 3:52 am

EDITED:
You can make it as screen

Code: Select all

screen sectet_item:
    imagebutton ... action[sectet_items+=1, Hide("secret_item")]

User avatar
orz
Regular
Posts: 126
Joined: Tue Apr 21, 2015 10:19 pm
Contact:

Re: Place Items in the Backgrounds and hide after click

#3 Post by orz » Tue Jul 21, 2015 12:11 pm

The problem with having multiple items on one screen, and then trying to hide the screen when you click on one... means they're all hidden.

Instead, make a variable and check that if it'll be drawn on the screen.

Here's a quick and very basic example:

Code: Select all

init python:
    secretitem1 = 0
    secretitem2 = 0

label start:
    "here's a test"
    show screen hideandseek
    "and now we see if it works"
    "I sure hope it does"
    return

screen hideandseek:
    if secretitem1 is not "Found":
        imagebutton idle "item1.jpg" hover "item1.jpg" pos (.1, .1) action SetVariable("secretitem1", "Found")
    if secretitem2 is not "Found":
        imagebutton idle "item2.jpg" hover "item2.jpg" pos (.8, .1) action SetVariable("secretitem2", "Found")

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Place Items in the Backgrounds and hide after click

#4 Post by Kia » Wed Jul 22, 2015 1:11 am

you can add lots of small screens on your screen simply by showing them

Code: Select all

label start:
    "here's a test"
    show screen hideandseek
    show screen item1
    show screen item2
    show screen item3
    show screen item4
    show screen item5
    "and now we see if it works"
    "I sure hope it does"
    return

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]