- —>Craftworld —>
- Renpy imagemap не работает
- Lemma Soft Forums
- Imagemaps explained by a dummy
- Imagemaps explained by a dummy
- Lemma Soft Forums
- Seriously specific functions on an imagemap. ideas?
- Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
- Re: Seriously specific functions on an imagemap. ideas?
—>Craftworld —>
#настройки экрана вызываются отдельным блоком screen
screen example_imagemap:
#определяем что это imagemap
imagemap :
#это картинка которая отображается
ground » images/ground.jpg »
#это отредактированная картинка которая отображается поверх
#эти картинки не нужно прописывать в init
hover » images/hover.jpg »
#в скобках первые два значения отображают верхний левый угол активной области
#следующие два это ширина и длина области
#clicked означает что если на область кликнуть, то произойдет действие Return()
#которое примет значение указанное в скобках
hotspot (385, 315, 78, 78) clicked Return(» home «)
hotspot (435, 365, 78, 78) clicked Return(» school «)
hotspot (485, 415, 78, 78) clicked Return(» bank «)
hotspot (535, 465, 78, 78) clicked Return(» hospital «)
label example_label:
#как видим блок окна вызывается отдельно, чтобы не прописывать его каждый раз
call screen example_imagemap
#наш результат прошлого выбора в меню, благодаря действию Return()
#был сохранен в хранилище _return
$ result = _return
#теперь результат действий щелчка будет зависеть, от выбора который мы сделали ранее
if result == » home «:
p » Вы выбрали дом! »
elif result == » school «:
p » Вы выбрали школу! »
elif result == » bank «:
p » Вы выбрали банк! »
elif result == » hospital «:
p » Вы выбрали больницу! «
Источник
Renpy imagemap не работает
Варвара, ошибка в 240 строке — вместо elif нужно использовать else
ошибка в 275 — поехали отступы в строках 274-277
по 2й проблеме ничего не могу сказать
Варвара, вторая проблема — она не проблема, так и должно быть. Вот эта конструкция $ result = renpy.imagemap. — это как call screen название_экрана, показывает только imagemap и ждет действия от игрока. Если нужно видео на фоне, то надо переделать эту часть кода. Например, сделать экран в котором будет показано видео, а поверх него уже будет imagemap (см. ЧаВо как добавить видео в главное меню).
https://www.renpy.org/doc/html/screens.html
https://www.renpy.org/doc/html/screens.html#add
https://www.renpy.org/doc/html/screens.html#imagemap-..
При попытке запуска «Доков-доков» в Ren’Py 7.1.0.882 под Андроид выдаёт:
File «game/definitions.rpy», line 28, in
user_dir = os.environ[«ANDROID_PUBLIC»]
KeyError: u’ANDROID_PUBLIC’
Полгода назад всё прекрасно собиралось и работало.
Подскажите, пожалуйста, в чём проблема и как можно получить полный путь к директории публичных данных игры, если это не баг, а фича. Ну, кроме вариант найти старую версию RenPy, под которой всё работало, конечно.
Поиск в интернете за разумное время вменяемого результата не дал 🙁
Yurik, есть вероятность что ты на пк запускаешь проект под андроид
Из старых версий вроде на Оф сайте можно скачать более старый репай
Витя, именно так. Но, чтобы собрать проект под Андроид, в Ренпае нужно для начала его каким-то образом запустить. И вот тут-то и возникает главная проблема: как? 🙁
Попробовал уже, в 6.99. Как я понимаю, проблема не в Ренпае самом, а в Андроидных библиОтеках, которые Ренпай выкачивает из инета. Но от этого не легче 🙁
Варвара, попрбую написать много букв.
Общие советы:
— все блоки init выполняются перед главным меню не зависимо от того, где в коде они написаны. Лучше писать их в начале скрипта или в отдельном файле (если их много).
— для единичных строк кода на питоне не обязательно делать блок
python:
renpy.music.queue(«Sam/YBF.wav»,channel = «music», fadein = 1)
можно просто в начале строки поставить знак $
$ renpy.music.queue(«Sam/YBF.wav»,channel = «music», fadein = 1)
— если в игре используются какие-либо константы (переменные, значения которых не будут изменяться в игре), то лучше всего объявить их командой define — она пишется вне блоков (без отступов), присвоение значения происходит до перехода в главное меню.
— если в игре есть переменные, значения которых будут изменяться, и их надо будет сохранять, то такие переменные надо объявить командой default — тоже пишется вне блока (без отступов). Удобно писать в начале скрипта или в отдельном файле rpy.
— объявление изображений происходит до перехода в главное меню не зависимо от того, в каком месте скрипта написан код. Т.е. все объявления image vrema = DynamicDisplayable(vrema, length=8.0) и image movie 2 = Movie(play=»images/Cutscene/Sad idle.mp4″, size=(config.screen_width, config.screen_height)) и т.д. будут исполнены до начала игры.
— создание экранов происходит до перехода в главное меню не зависимо от того, в какой строке находится код для экрана. Т.е. если в коде несколько раз создается screen QTE (экраны с одинаковым названием), то в результате будет только один экран с таким названием, код для которого был написан последним. Если нужны экраны с разным содержимым, то надо либо давать им разные названия (самый простой способ), либо делать один экран, содержимое которого определяется переменными, а при показе такого экрана передавать в него значения этих переменных.
$ result = renpy.imagemap — это очень старый код, он, конечно, работает, но сейчас все делается несколько иначе (проще).
Можно создать экран, который содержит imagemap, а в качестве действий для активных областей поставить прыжок на метку.
screen imgmap_1():
. modal True #заставит игрока взаимодействовать только с этим экраном
. imagemap:
. align (0.5,0.5) #положение imagemap посередине экрана (если картинки для него меньше размера экрана)
. idle «images/bg/buttons0.png»
. hover «images/bg/buttons.png»
. hotspot (x,y,w,h) action [Jump(«название_метки»), Hide(«imgmap_1»)] #координаты активных областей указываются в этом случае иначе: x,y — координаты левого верхнего угла области, w,h — ширина и высота области в пикселях. Несколько действий можно указать списком в квадратных скобках — в данном случае прыжок на метку и закрытие экрана с imagemap, т.к. он больше не нужен.
Такой экран надо будет показать командой show screen imgmap_1.
Если картинки для imagemap по размеру меньше экрана, то видео, которое было показано до показа экрана с таким imagemap’ом, будет видно на фоне.
С qte-игрой не совсем понял. Есть 2 переменные (q и e), в самом начале их значения 0. При показе экрана qte начинает работать таймер на 8 секунд, который перебрасывает игрока на какую-то метку, но если игрок нажмет хоть раз одну из кнопок q и/или e, то начнется другой таймер на 8 секунд, который перебросит игрока в другую метку. (?)
screen QTE:
if q == 0 or e == 0:
timer 8.0 action Jump(«pauk1O3»)
else:
timer 8.0 action Jump(«pauk1I3»)
Если суть в том, чтобы игрок успел нажать хоть одну кнопку, то можно прямо для кнопки определить список действий: прыжок на метку и скрытие экрана qte, а таймер будет только один, и он будет перекидывать на метку проигрыша и также скрывать экран qte.
Источник
Lemma Soft Forums
Supporting creators of visual novels and story-based games since 2003.
Visit our new games list, blog aggregator, IRC channel, and Discord.
NaNoRenO ends when April begins .
Activation problem? Email PyTom.
- Unanswered topics
- Active topics
- Search
- Members
- The team
Imagemaps explained by a dummy
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren’Py questions should be asked in the Ren’Py Questions and Announcements forum.
Imagemaps explained by a dummy
#1 Post by jane_runs_fast » Sat Oct 28, 2017 3:28 pm
Here is some code stuff that is ALREADY on lemmesoft- but as a noob with Renpy, this stuff took FOREVER for me to figure out how to make work.
I’m hoping to share the stuff I’ve learned and gathered in a way that will help other new people understand.
This stuff might not be the most efficient way to do things- but it works for me- so it should work for you.
Imagemaps
Imagemaps take up a lot more space than image buttons- but it is the easiest way to make something work if you are still new.
What you need to make one is:
- you need THREE fixed images ‘.JPG or PNG. of the SAME thing to make an image map.(as in everything is in three separate images. you don’t need a new image for a specific button if you are making an imagemap.)
- You need to have the coordinates of your ‘hotspots’
- You need to have the code stuff set up to make everything work.
First I will give an example and explanation of the images you will need for your imagemap.
Then I will explain ‘Hotspots’ and how to find them.
Last I will give you the code that I have been using for my example menu
Below I will be using sprites and backgrounds from a game that does not belong to me as examples.
Example imagemap menu:
Here is the ‘ground’ image’ If there is no working ‘hotspot’ attached to anything the image will look like this. So fade or darken any ‘buttons’ or areas that you want others to know when they are not working. Like the ‘read story’ button below- If it is not working it will be dark.
Here is the ‘hover’ image. If you have a working ‘hotspot’ the section of the image will look like this when you have your mouse hovered over it. if you want your button or area to change color, shape, whatever when someone hovers over it- this is the image that will appear when that happens. I want my buttons to change colors, So I made my start button green, and my other buttons a pink pattern.
Here is the ‘idle’ image If you have a working ‘hotspot’ and your mouse is hot ‘hovered’ over the working area your image will look like this.
Idle when the screen is not being ‘touched’ or messed with by a player. When my screen is left along, I want my buttons to be plain and white.
Now that you have THREE separate images we need to find our ‘Hotspots»
Hotspots
Hotspots are rectangular or square (I’m sure there is a way to make other shapes, but I don’t know it) position locations that you use to make an area of your image ‘clickable’.
The coordinates that work for me are
‘Xcoordinate’, ‘Ycoordinate’, ‘Height’, and ‘Value’ in that order.
To find X and Y
X and y coordinates are found in the upper left corner of the position you are wanting to turn into a hotspot.
Lets say the ‘read story button’ on my menu is what I want to get the x and y coordinates for. the specific point that I need is the UPPER LEFT CORNER of the ‘Read Story button’. Anywhere else will cause your hotspot to move.
you can use any illustration software to find x and y for a position, but the most dependable way to find the x and y coordinates is through the ‘developer keys’ already in Renpy.
I will show you how to find x and y in your game.
First- you need to have your images (ground, idle, and hover) in the game folder labeled ‘images’
Now open renpy and LAUNCH YOUR PROJECT (the one that contains your menu images)
Once you are on the main screen of your game press ‘SHIFT» and «D» on your keyboard to bring up the Developers Menu.
Now you have the Developers menu up on your screen. It should look like the image below.
Now click the text link labeled «Image Location Picker»
It looks super confusing- especially if you already have alot of images in your game. Just scroll through until you find one of your three menu images. Click on it and that image will pop up.
As you move your cursor around the image the numbers on the bottom left of the screen will change. These numbers are your coordinates.
Take your cursor and place it on the upper left of the area you want to turn into a hotspot. your exact x and y coordinates will be shown in the bottom left of the renpy screen. (highlighted in yellow in the image below.)
if you want the height and value of the area as well —
(With your cursor in the upper left corner of the area you want to select)
Hold down the left button on your mouse and drag your cursor to the loser right corner of the area you want to become a hotspot. A light blue box should appear as you drag your cursor.
Once your blue box is where it needs to be, release the button on your mouse.
your coordinate numbers should be on the bottom left of your renpy screen- all ready for you to use.
Now you have your x and y coordinates. (You will see where to put them in the code below.)
Below is the code I use- iI replaced the stuff in the navigation screen with my imagemap stuff.
It might be super sloppy- but everything here works and is pretty simple to put together. Google has been a godsend- Anything I have not been able to bumble through on my own I search in lemmasoft or type ‘renpy ‘blah blah blah’ ‘ into google.
Источник
Lemma Soft Forums
Supporting creators of visual novels and story-based games since 2003.
Visit our new games list, blog aggregator, IRC channel, and Discord.
NaNoRenO ends when April begins .
Activation problem? Email PyTom.
- Unanswered topics
- Active topics
- Search
- Members
- The team
Seriously specific functions on an imagemap. ideas?
Seriously specific functions on an imagemap. ideas?
#1 Post by vaanknight » Sun Aug 15, 2010 6:55 pm
Okay, I already posted this code before, but it was to take care of a different problem, so allow me to discuss it from scratch here.. I’ve already taken care of the issue over there, but I left this other one for later, and I suppose now is later.
I have my script up and running with no problems, it works as it should, but picky as I am I want it to run exactly the way I want. :/
The true code is WAY too large to post it here, so instead let’s say I have this code:
With this code, the user clicks on a button to listen to a tune while an image shows up with details about the music. BUT. as you can tell by reading the above code, the user would have to click again to be able to go back to the imagemap and click on another tune, which while it keeps playing the tune, hides the forementioned image.
What I want is the image to show and the tune to play, but while they’re still on screen, the user should be able to browse the other buttons normally. with the hover functions and all.
Any ideas? . need me to rephrase? ‘cuz I barely understand myself here sometimes. xP
Re: Seriously specific functions on an imagemap. ideas?
#2 Post by KimiYoriBaka » Sun Aug 15, 2010 11:06 pm
Does it still work if you don’t have the renpy.pause()? cause I don’t see any reason for it to be there.
As far as showing the buttons and the image at the same time, I think you just need the ground and hover images to be transparent at that part of the screen. Of course, I haven’t tried it myself, but if that doesn’t work, there’s always ui.buttons.
Re: Seriously specific functions on an imagemap. ideas?
#3 Post by vaanknight » Mon Aug 16, 2010 11:49 am
Oh it all works just fine, I use the pause function to avoid the image to show for an instant and then jump back to the imagemap, with the pause, the user clicks on the button, then the image shows but it doesn’t vanish until the next click.
And yes, I use transparent PNGs, so they show just well, where they should and all, what I need is the imagemap working with the hover functions and everything while the last image is still showing.
Let’s put it this way: My question is How do I set an image to show so it doesn’t dissapear when ren’py jumps to the imagemap, unless I tell it to hide?
Re: Seriously specific functions on an imagemap. ideas?
#4 Post by Jake » Mon Aug 16, 2010 12:04 pm
Re: Seriously specific functions on an imagemap. ideas?
#5 Post by vaanknight » Mon Aug 16, 2010 12:11 pm
Re: Seriously specific functions on an imagemap. ideas?
#6 Post by KimiYoriBaka » Mon Aug 16, 2010 1:18 pm
Re: Seriously specific functions on an imagemap. ideas?
#7 Post by Jake » Mon Aug 16, 2010 3:41 pm
There must be something else wrong with your code, then, because I copied and pasted the code above and it worked absolutely fine for me with ground and hover images that had transparent backgrounds. I’ve attached the modified version of my code to this post, you can compare it to what you’ve got already.
As KimiYoriBaka notes, you can use the renpy.transition() to get the imagemap to show with a dissolve, but it will always just disappear abruptly. One way to get around this is simply to define a Ren’Py image for your imagemap ground image, and show that with a dissolve immediately before your imagemap, and then hide it with a dissolve immediately afterward. The user probably won’t notice (or care) that they can’t click the imagemap buttons while they’re fading in and out, and it looks a lot nicer.
(You can do all this ‘properly’ with the Displayable versions of the UI Button and Image widgets, but if you’re using imagemaps ’cause they’re easier than UI then that solution is in completely the wrong direction complexity-wise.)
Re: Seriously specific functions on an imagemap. ideas?
#8 Post by vaanknight » Mon Aug 16, 2010 6:26 pm
I usually do precisely that, but the problem is that using the show statement, the images appearing from the clicked tune buttons stack up one over the other and make it look like a mess. instead I include the ground.png image with the «scene» statement just before the imagemap, which obviously is the root of my «dissapearing» trouble, but it’s necessary to avoid having each and every clicked image there. so what I want is to be able to keep the image in its place while the imagemap shows up again after the user’s click that jumps to the start of the label.
Just as I write this, though. I think I have an idea of how to get exactly what I want, using the renpy.transition() thingie KimiYoriBaka mentioned, but noob question. where do I put it?
Re: Seriously specific functions on an imagemap. ideas?
#9 Post by Jake » Mon Aug 16, 2010 6:36 pm
Indeed it is! You didn’t mention the ‘scene’ before, it’s definitely the cause — that statement removes everything from the screen.
If you don’t want your displayed images to ‘stack up’ there’s a far simpler way to do it than blitzing everything: just make sure they all have the same tag.
The ‘tag’ of an image is the first part of its defined name. So if you have a set of images like:
all of these images have the same tag: «eileen». Whenever any of them is shown, Ren’Py searches the scene for already-shown images with the tag ‘eileen’ and if it finds one, instead of just showing the new image over the top, it replaces the existing image with the new one. So there will never be more than one image on-screen with the same tag at the same time unless you deliberately tell Ren’Py to do that.
So in this case, instead of defining your images as «pic_one», «pic_two», etc., you could define them as «pic one», «pic two» and so on, and you’ll get the same behaviour — Ren’Py will automatically replace «pic one» with «pic three» and then later replace «pic three» with «pic two», because they have the same tag.
(In fact, if you look at the example code I posted, you’ll see I did just this with the images I defined in there, for the same reason.)
Источник