Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to add background behind visualchoice #25

Closed
JohanForngren opened this issue Sep 14, 2021 · 1 comment
Closed

Be able to add background behind visualchoice #25

JohanForngren opened this issue Sep 14, 2021 · 1 comment

Comments

@JohanForngren
Copy link
Contributor

I don't if this is useful to anyone else, but on the projects I'm working on I need to show a background image behind the visual choices. I would like to be able to specify a background image i GUI.yaml, and if it's present show it behind every visual choice.

Right now I'm doing something like this in lots of places:

  - text: Time to choose...
  - hide CGS: WITH CUT
  - show VC3A: AT VC3A WITH CUT # This is a background image for choices
  - show VC3B: AT VC3B WITH CUT # The same image, with another name to show it in multiple places at once
  - show VC3C: AT VC3C WITH CUT # And again...
  - visualchoice:
    - flickan says: Jag vill att min vän ska vara...
    - choice_likeyou AT VC3A:
      - var girlsChoice: 'likeyou'
      - var girlsChoiceText: 'lik flickan'
    - choice_curious AT VC3B:
      - var girlsChoice: 'curious'
      - var girlsChoiceText: 'nyfiken'
    - choice_soccer AT VC3C:
      - var girlsChoice: 'soccer'
      - var girlsChoiceText: 'bra på fotboll'
  - hide CGS: WITH CUT

Maybe this feature is to specific for RenJS core and should be made as a plugin instead?

@lunafromthemoon
Copy link
Owner

I think it's too specific, but you can do this by adding a transition for the visualChoices with a plugin:
The transition for visual choices will receive a display object where each child is one of the visual choices elements, so you'd need to loop its children to add the background. Something like this:

from,to =>
(if hiding)
if !to return FADE (or any other transition you want to use)
(if showing)
for child in to.children:
create background
add background to "to" in correct position
send child to front (this is to make sure child will be on top of background)
return FADE (or any other transition you want)

That's more or less what the transition should do, then you set this transition as the default transition for visual choices. Check this to see how to add new transitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants