[Solved] Having problems. Can you help with a simple jukebox?

dipstick5000

  • Posts: 47
I have 2 buttons to play 2 different parts of a sound, with 3 animations each. For both buttons, Animation 0 (for the normal state) and Animation 1 (for the mouse enters state) have 1 frame, and Animation 2 has 2 frames (for the active or current state). So animations 0 and 1 aren't technically animated.

I have a looping 10 second sound that starts when the scene is created. I have a drawing event that checks the position of the sound. If the sound is within the first 5 seconds, animation 2 of button 1 plays. If it's within the last 5 seconds, animation 2 of button 2 plays. This works perfectly.

I have an on actor event for each button. When the mouse is released on button 1, the position of the sound is set to 0. When it's released on button 2, the position of the sound is set to 5000 (the 5 second mark). This also works perfectly, but that's where I'm stuck.

I can't get the hover state to work, which is Animation 1 for each button. I've tried making regions over the buttons, so when mouse enters the region, hover, or mouse enter (Animation 1) is triggered, but that does nothing as well. I've tried making behaviors instead of events, but I can't choose actors or animations in a behavior, only attributes or last created actor.

Am I going about this wrong? What would you do? Would it be easier to make several sounds instead of getting parts of one sound?

Goals:
- Songs, or parts of one sound play in order and start over when all have played.
- Clicking a song (actor button) stops current song and starts a new one, but songs will continue to play in order otherwise.
- Current song keeps playing on scene change.
- Animation plays on proper button (actor) when corresponding song is playing.
- Hover or mouse enter triggers Animation 1 on actor button (a single frame animation).

« Last Edit: January 10, 2020, 09:47:37 pm by dipstick5000 »
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

vicevicebingo

  • Posts: 80
if + and

if + and + and

if + and + and + and

if + and + and + and + and

Luyren

  • *
  • Posts: 2741
Set a boolean to true if the mouse enters your actor, set it to fase when it leaves the actor.
Put your drawing code inside an "if <not <boolean>."

Your drawing code is voerwritting the animation of your actor constantly. By adding that boolean, it won't do that if the mouse is inside your actor.

Quote
I've tried making behaviors instead of events, but I can't choose actors or animations in a behavior, only attributes or last created actor.
You must create attributes of the type you want to use. You can select animations if you create an attribute of type "Animation."
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

dipstick5000

  • Posts: 47
Thank you very much vicevicebingo and Luyren. You gave me good ideas that I played around with. I need to learn attributes and messaging behaviors better, but I haven't yet, so I may have went about it “wrong.” Anyway I solved it fairly simply. Whenever you've got a frustrating head scratcher, you should always take a break from it at some point. I took a nap and woke up thinking of hiding layers. I made a layer for each “active” button (actor), or each button that corresponds to the playing song. I only show it if the song is playing. I realize this is probably more resource intensive, but I have a small scene and it shouldn't matter much.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.