Page 1 of 1

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

Posted: Mon Nov 12, 2018 2:23 pm
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!

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

Posted: Tue Nov 13, 2018 1:24 am
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.

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

Posted: Tue Nov 13, 2018 2:15 am
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...

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

Posted: Tue Nov 13, 2018 6:03 pm
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
 

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

Posted: Thu Nov 15, 2018 2:13 pm
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. :)

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

Posted: Sat Nov 17, 2018 5:22 am
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."

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

Posted: Sat Nov 17, 2018 9:14 am
by Spoons
Use call screen instead of show.

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

Posted: Sat Nov 17, 2018 12:54 pm
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.

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

Posted: Sun Nov 18, 2018 4:17 am
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!