Making a moving displayable clickable/shootable [SOLVED]
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.
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.
Making a moving displayable clickable/shootable [SOLVED]
I'm wondering if something like that would be possible without needing a pygame framework.
I'm not looking for anything fancy, like an fps or whatever. I'm just wondering if it's possible within ren'py proper, to have an event where a moving displayable can be "shot at" by clicking on it with the mouse.
Once the displayable is shot, either the event jumps to a new label, or the displayable calls in another image ( like a target at the first that then becomes a target with a bullet hole ).
The idea came up playing " Crimsoness" in whitch there is a timer and an imagemap, but imagemap can't move can it ?
Also, could the cursor be crosshaired for just this event ?
Thanx for any input on this. :)
I'm not looking for anything fancy, like an fps or whatever. I'm just wondering if it's possible within ren'py proper, to have an event where a moving displayable can be "shot at" by clicking on it with the mouse.
Once the displayable is shot, either the event jumps to a new label, or the displayable calls in another image ( like a target at the first that then becomes a target with a bullet hole ).
The idea came up playing " Crimsoness" in whitch there is a timer and an imagemap, but imagemap can't move can it ?
Also, could the cursor be crosshaired for just this event ?
Thanx for any input on this. :)
Last edited by blakjak on Mon Jan 26, 2009 8:57 am, edited 2 times in total.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Making a moving displayable "clickable" for a sniping event
You can certainly use ui.at with Move and an ui.imagebutton. You can also use user-defined displayables for more complexity and control.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: Making a moving displayable "clickable" for a sniping event
Thank you for your reply, I'll look into that.
Re: Making a moving displayable "clickable" for a sniping event
Ok so I've come up with some sort of mini demo. Please unzip in the renpy main folder, and tell me what you guys think, I'm a beginner coder, so there may have things I overlooked.
BTW does anyone know if it is possible to have both a move function and a factorzoom on a displayable ? Like what exists for Rotozoom, but with Move ?
BTW does anyone know if it is possible to have both a move function and a factorzoom on a displayable ? Like what exists for Rotozoom, but with Move ?
- Attachments
-
- game.zip
- (638.81 KiB) Downloaded 72 times
Last edited by blakjak on Fri Jan 02, 2009 6:51 pm, edited 1 time in total.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Making a moving displayable "clickable" for a sniping event
Yeah, you can just compose Move and Zoom. Something like:
The one thing is that it may not be possible to FactorZoom a button. That's something I'm considering trying to address. The next release of Ren'Py will have a mildly more convenient way of doing this.
Code: Select all
ui.add(At("foo.png", FactorZoom(...), Move(...))
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: Making a moving displayable clickable/shootable : solved
Ok well I think I'm doing something wrong here because I can't figure out how the ui.add function can control the ui.imagebutton's behaviour ( it does work very well but with an image only).
No worries though, my aim was to have a moving dysplayable shootable, and that works fine.
Thank you again.
Code: Select all
$ ui.add(At( "target.png", FactorZoom(1.0, 3.0, 2.0, opaque=False), center, Move((0.2, 0.5), (0.8, 0.5), 1.0, repeat=True, bounce=True,
xanchor="center", yanchor="center")))
$ ui.at (FactorZoom(1.0, 3.0, 2.0, opaque=False), center, Move((0.2, 0.5), (0.8, 0.5), 1.0, repeat=True, bounce=True,
#xanchor="center", yanchor="center"))
# Defining the u.i imagebutton for the target and specifying the label it calls.
$ ui.imagebutton("target.png", "target.png", clicked=ui.returns (1))
$ result = ui.interact()
if result == 1:
jump target_hit
Thank you again.
-
- Veteran
- Posts: 398
- Joined: Sat Jul 12, 2008 1:31 pm
- Projects: Kassiopeia [iVN]
- Location: Deutschland
- Contact:
Re: Making a moving displayable clickable/shootable : solved
Looking good!
Afaik "ui." is on the transient layer and cannot be behind a shown scene on the master layer? I didn't try ui.layer in that respect, yet.
Now, can a moving clickable displayable be placed behind another image?Widget
These are generally used with the ui functions, but may sometimes be used as displayables.
Afaik "ui." is on the transient layer and cannot be behind a shown scene on the master layer? I didn't try ui.layer in that respect, yet.
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Making a moving displayable clickable/shootable : solved
I think you can. The concept is the more later you code an ui, the more front it becomes. The following code should show you the clickable behind another clickable.
Edit: Turns out the there's an indentation problem with the given code. Edited it.
Code: Select all
$ ui.at(Move((0.0, 0.5, 1.0, 0.5), (0.5, 0.5, 0.5, 0.5), 1.0))
$ ui.textbutton("Click Me!", clicked=ui.jumps('start'),xminimum=200, yminimum=200)
$ ui.textbutton('hekko',clicked=ui.jumps('start'),xpos=0.4, ypos=0.4, xminimum=100, yminimum=100)
$ ui.interact()
Last edited by JQuartz on Fri Jan 09, 2009 4:29 pm, edited 2 times in total.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
Re: Making a moving displayable clickable/shootable : solved
This is sweet, I could actually use this type of code in my project
Re: Making a moving displayable clickable/shootable : solved
This is interesting, it means If the player cliks outside the moving displayable, then the clickable behind could act as a "missed your shot" region.JQuartz wrote:I think you can. The concept is the more later you code an ui, the more front it becomes. The following code should show you the clickable behind another clickable.Edit: Turns out the there's an indentation problem with the given code. Edited it.Code: Select all
$ ui.at(Move((0.0, 0.5, 1.0, 0.5), (0.5, 0.5, 0.5, 0.5), 1.0)) $ ui.textbutton("Click Me!", clicked=ui.jumps('start'),xminimum=200, yminimum=200) $ ui.textbutton('hekko',clicked=ui.jumps('start'),xpos=0.4, ypos=0.4, xminimum=100, yminimum=100) $ ui.interact()
Correct me if I'm wrong but I recall that being discussed in a thread , specifically that having a button on top of another is not recommended ?
Anyway, I'll have to try this at home. thanx for the idea.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]