Showing images on my Image Maps

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
Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Showing images on my Image Maps

#1 Post by Exiscoming » Wed Apr 30, 2014 6:21 pm

Right, tricky one for me. In my game you can recruit soldiers and this is done via an Image Map where you can cycle though troops to hire. The Imagemap itself looks like this:

Image

Now I like to have certain images overlay, depending on where you cycle through it. Like this for example:

Image

However when I do this:

Code: Select all

call screen recruitment   #The imagemap
show spearman1            #The image
It doesn't show the spearman. I know that it's there, but it's hidden behind the image map. Is there a way I can allow certain images to be layered 'over' the image map?
I had a look at

Code: Select all

config.layers = [ 'master', 'transient', 'screens', 'overlay' ]
on the wiki, but I'm not entirely sure how to implement a new layer. Any advice on the best way to solve this problem would be greatly appreciated.
Last edited by Exiscoming on Wed Apr 30, 2014 10:05 pm, edited 2 times in total.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Showing images on my Image Maps

#2 Post by Asceai » Wed Apr 30, 2014 6:24 pm

Are you sure it's there? 'call screen' doesn't return control to the caller until a Return action is used (or the screen is returned to in some other way)
Try 'show screen' instead.

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Showing images on my Image Maps

#3 Post by Exiscoming » Wed Apr 30, 2014 6:40 pm

Asceai wrote:Are you sure it's there? 'call screen' doesn't return control to the caller until a Return action is used (or the screen is returned to in some other way)
Try 'show screen' instead.
Yes and no haha, okay here's my code:

Code: Select all

    label barracks_1:
                $ menu_flag = True
                call screen recruitment                                                 #armyManagement.rpy recruit warriors


label buySpearman:
    scene recruitmentDemo1Scene    #keep an eye on this.
    show spearman1
    $ soldierA += 1
    "You now have [soldierA] spearmen."
When I click "Hire" on my image map. The imagemap disapears and shows the underlying image (in this case my barracks placeholder)
Image

To counter this, I've added a:

Code: Select all

    scene recruitmentDemo1Scene
in my label buySpearman. So that it shows the brown background, rather than the barracks placeholder.
In other words, the image 'is' there, its just being obscured by the overlaying Imagemap screen. Changing the call screen to show screen simple makes the game jump to the next call screen in the code.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Showing images on my Image Maps

#4 Post by Asceai » Wed Apr 30, 2014 6:55 pm

Alright. I still don't understand exactly what you're doing, but you can create a new layer and show the image on that.

Code: Select all

init python:
  config.layers = [ 'master', 'transient', 'screens', 'above_screens', 'overlay' ]

Code: Select all

show spearman1 onlayer above_screens

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Showing images on my Image Maps

#5 Post by Exiscoming » Wed Apr 30, 2014 7:00 pm

Asceai wrote:Alright. I still don't understand exactly what you're doing, but you can create a new layer and show the image on that.

Code: Select all

init python:
  config.layers = [ 'master', 'transient', 'screens', 'above_screens', 'overlay' ]

Code: Select all

show spearman1 onlayer above_screens
haha, yeah I feel like I'm jerryrigging this thing. Hm, it seems that it still doesn't work. The image map is still overlaying, making the spearman hide behind it.
Perhaps I'm going to have to find another way of doing this.

I'm using a lot of image maps as navigation tools, rather then just putting up Menu options. This is basicly what I'm trying to acomplish:

>Imagemap recruitment menu
>Spearman graphic on top of it.
>Still being able to click on the Imagemap recruitment menu.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Showing images on my Image Maps

#6 Post by Asceai » Wed Apr 30, 2014 7:11 pm

Add another screen and make that screen just show the spearman. Then give it a high zorder so it appears on top of the other screen.

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Showing images on my Image Maps

#7 Post by Exiscoming » Wed Apr 30, 2014 7:39 pm

Asceai wrote:Add another screen and make that screen just show the spearman. Then give it a high zorder so it appears on top of the other screen.
Alright! I don't know how... but somehow I did it! ... seriously it suddenly works and I'm still wondering why... haha. However with that came a new problem.
(Thanks for giving me a hand by the way.)


I want to add a miniature version of the soldier to the right side of the screen. And this works with this code:

Code: Select all

label buySpearman:
    scene recruitmentDemo1Scene
    $ soldierA += 1
    show spearmini at Position (xpos = 470, ypos = 300) onlayer above_screens
    "You now have [soldierA] spearmen."
    
    jump barracks_1 #In barracks_1 there's an imagemap where if you click on the "Back" button, it sends you to exitRecruitment
    
label exitRecruitment:
    hide spearmini
    
    jump Barracks
However the spearmini doesn't disapear.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Showing images on my Image Maps

#8 Post by Asceai » Wed Apr 30, 2014 7:41 pm

'hide' requires onlayer as well
hide spearmini onlayer above_screens

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Showing images on my Image Maps

#9 Post by Exiscoming » Wed Apr 30, 2014 7:50 pm

Asceai wrote:'hide' requires onlayer as well
hide spearmini onlayer above_screens
Dude, you're awesome. Thanks! Ugh... I'd hate to ask (you've already helped me so much :D) but while I'm at it... right now when I recruit a soldier, it looks like this:

Image

Is there a script I can add to it, which makes the next time I recruit a soldier (and then a third), make it look like this?

Image

Or should I change my code into:

Code: Select all

$ spearman = 0  #show no mini spearmen
if spearman == 1
show show spearmini at Position (xpos = 480, ypos = 250) onlayer above_screens
elseif == 2
show spearmini at Position (xpos = 500, ypos = 250) onlayer above_screens
What do you think is easier / more professional?
(and if you have gotten sick of my questions, that's fine too haha, you've already been a huge help!)

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Showing images on my Image Maps

#10 Post by Asceai » Wed Apr 30, 2014 7:55 pm

You'll need to use 'as' for subsequent images because there can only be one image with a given tag per layer.

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Showing images on my Image Maps

#11 Post by Exiscoming » Wed Apr 30, 2014 8:17 pm

Asceai wrote:You'll need to use 'as' for subsequent images because there can only be one image with a given tag per layer.
It's working exactly how I want it now. Thanks!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]