[Solved]Have a character move to the left when clicking on it and showing a menu when clicking on it

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
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

[Solved]Have a character move to the left when clicking on it and showing a menu when clicking on it

#1 Post by TsukiWorks »

Hello! I'd like to know how to make a character move from its current position when clicked, and also make a menu appear when you click on the character. Thanks in advance!
Last edited by TsukiWorks on Sun Nov 18, 2018 4:18 am, edited 1 time in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#2 Post by Per K Grok »

TsukiWorks wrote: Mon Nov 12, 2018 2:23 pm Hello! I'd like to know how to make a character move from its current position when clicked, and also make a menu appear when you click on the character. Thanks in advance!
You could use a mousearea placed over the character, that jump to an label that move the character and opens the menu.

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#3 Post by TsukiWorks »

Per K Grok wrote: Tue Nov 13, 2018 1:24 am
TsukiWorks wrote: Mon Nov 12, 2018 2:23 pm Hello! I'd like to know how to make a character move from its current position when clicked, and also make a menu appear when you click on the character. Thanks in advance!
You could use a mousearea placed over the character, that jump to an label that move the character and opens the menu.
And how do I do that? Sorry, my skills in programming are kinda low...

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#4 Post by Per K Grok »

TsukiWorks wrote: Tue Nov 13, 2018 2:15 am
Per K Grok wrote: Tue Nov 13, 2018 1:24 am
TsukiWorks wrote: Mon Nov 12, 2018 2:23 pm Hello! I'd like to know how to make a character move from its current position when clicked, and also make a menu appear when you click on the character. Thanks in advance!
You could use a mousearea placed over the character, that jump to an label that move the character and opens the menu.
And how do I do that? Sorry, my skills in programming are kinda low...

Sorry, I miss remembered what mousearea can do. Instead you could use button.

You could test something like this.

Code: Select all

image char = "yaz_S1.png"

screen charClick():
    button:
        area(500,200,100,200)
        action Jump("moveLeft")

label start:

    scene bg bg1
    show char:
        pos(500,200)
    show screen charClick()

    $ renpy.pause( hard=True)

label moveLeft:
    show char:
        pos(500,200)
        linear 3.0 xpos 100


    menu:
        "Question"
        "Yes":
            return
        "No":
            return
 

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#5 Post by TsukiWorks »

Per K Grok wrote: Tue Nov 13, 2018 6:03 pm
TsukiWorks wrote: Tue Nov 13, 2018 2:15 am
Per K Grok wrote: Tue Nov 13, 2018 1:24 am

You could use a mousearea placed over the character, that jump to an label that move the character and opens the menu.
And how do I do that? Sorry, my skills in programming are kinda low...

Sorry, I miss remembered what mousearea can do. Instead you could use button.

You could test something like this.

Code: Select all

image char = "yaz_S1.png"

screen charClick():
    button:
        area(500,200,100,200)
        action Jump("moveLeft")

label start:

    scene bg bg1
    show char:
        pos(500,200)
    show screen charClick()

    $ renpy.pause( hard=True)

label moveLeft:
    show char:
        pos(500,200)
        linear 3.0 xpos 100


    menu:
        "Question"
        "Yes":
            return
        "No":
            return
 
Thank you very much! I'll test it out and see if it works. :)

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#6 Post by TsukiWorks »

Per K Grok wrote: Tue Nov 13, 2018 6:03 pm
TsukiWorks wrote: Tue Nov 13, 2018 2:15 am
Per K Grok wrote: Tue Nov 13, 2018 1:24 am

You could use a mousearea placed over the character, that jump to an label that move the character and opens the menu.
And how do I do that? Sorry, my skills in programming are kinda low...

Sorry, I miss remembered what mousearea can do. Instead you could use button.

You could test something like this.

Code: Select all

image char = "yaz_S1.png"

screen charClick():
    button:
        area(500,200,100,200)
        action Jump("moveLeft")

label start:

    scene bg bg1
    show char:
        pos(500,200)
    show screen charClick()

    $ renpy.pause( hard=True)

label moveLeft:
    show char:
        pos(500,200)
        linear 3.0 xpos 100


    menu:
        "Question"
        "Yes":
            return
        "No":
            return
 
I tested the code, it's working. But I can still click outside the area (including the textbox). I only want the menu to appear and the character to move when I'm clicking on him. Am I doing something wrong?

Code: Select all

image char = "mamoru.png"

screen charClick():
    button:
        area(400,50,100,200)
        action Jump("moveLeft")
label start:
    show char:
        pos(400,50)
    show screen charClick()

    $ renpy.pause()

label moveLeft:
    show char:
        pos(400,50)
        linear 1.0 xpos 50
    menu:
        "Do you believe in love?"
        "Yes":
            k "What a strage question..."
            k "But to be honest with you...I do."
        "No":
            k "What a strage question..."
            k "But to be honest with you...I don't."

User avatar
Spoons
Newbie
Posts: 10
Joined: Tue Nov 13, 2018 4:39 am
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#7 Post by Spoons »

Use call screen instead of show.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#8 Post by Per K Grok »

TsukiWorks wrote: Sat Nov 17, 2018 5:22 am

I tested the code, it's working. But I can still click outside the area (including the textbox). I only want the menu to appear and the character to move when I'm clicking on him. Am I doing something wrong?

I used a hard pause. You cannot pass a hard pause with a mouse-click.

You use an ordinary pause. That will be ended with a mouse-click. That would be what happens when you click outside the button. The pause ends and the program continues to the next lines of code, which is the code that moves the character and shows the menu.

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Have a character move to the left when clicking on it and showing a menu when clicking on it

#9 Post by TsukiWorks »

Per K Grok wrote: Sat Nov 17, 2018 12:54 pm
TsukiWorks wrote: Sat Nov 17, 2018 5:22 am

I tested the code, it's working. But I can still click outside the area (including the textbox). I only want the menu to appear and the character to move when I'm clicking on him. Am I doing something wrong?

I used a hard pause. You cannot pass a hard pause with a mouse-click.

You use an ordinary pause. That will be ended with a mouse-click. That would be what happens when you click outside the button. The pause ends and the program continues to the next lines of code, which is the code that moves the character and shows the menu.
I see. I managed to solve the problem by using an imagebutton, but thank you for this other solution!

Post Reply

Who is online

Users browsing this forum: No registered users