[22 Jul 2006] Overlapping Buttons

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

[22 Jul 2006] Overlapping Buttons

Post by NathanH »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 02:50:56 -0000

Hi,

I just bought Hollywood and have started experimenting with it on AOS4. I envision writing a card game so am dinking around with sprites and buttons to try to figure things out.

I'd like to display a sprite for each card and immediately after displaying/moving the card make a button with the same dimensions right on top of it. Unfortunately, it appears that while sprites display in front of each other -- most recently displayed on the front -- overlapping buttons display behind each other -- most recent button is behind other buttons. E.g.,

Code: Select all

; a hollywood script

@bgpic  1, "BG.iff"
@sprite 1, "56cards.png", {x= 1, y=1, width=72, height=96, Frames=1, FPR=1}
@sprite 2, "56cards.png", {x=74, y=1, width=72, height=96, frames=1, fpr=1}

function p_ButtonClick(msg)
    debugprint("Left Button Clicked on ", msg.id)
endfunction

displaysprite(1,50,50)
makebutton(1,#SIMPLEBUTTON, 50, 50, 72, 96, {onmousedown=p_ButtonClick})

displaysprite(2,75,50)
makebutton(2,#SIMPLEBUTTON, 75, 50, 72, 96, {onmousedown=p_ButtonClick})

repeat
    waitevent
forever
Sprite two is in front of sprite one but button 2 is _behind_ button 1 so I'd have to free and remake all buttons in reverse order each time a card was moved and it overlapped existing cards.

If Hollywood traversed the button list in reverse order I'd probably be fine. Is there an easy way around this or should I use layers or brushes instead of sprites?

Thanks in advance for the help. Still having fun!

Nathan
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[22 Jul 2006] Re: Overlapping Buttons

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 11:48:52 +0200
Hi,

I just bought Hollywood and have started experimenting with it on AOS4. I envision writing a card game so am dinking around with sprites and buttons to try to figure things out.

I'd like to display a sprite for each card and immediately after displaying/moving the card make a button with the same dimensions right on top of it. Unfortunately, it appears that while sprites display in front of each other -- most recently displayed on the front -- overlapping buttons display behind each other -- most recent button is behind other buttons.
Yes, that is the case with buttons.

[...]
Sprite two is in front of sprite one but button 2 is _behind_ button 1 so I'd have to free and remake all buttons in reverse order each time a card was moved and it overlapped existing cards.

If Hollywood traversed the button list in reverse order I'd probably be fine. Is there an easy way around this or should I use layers or brushes instead of sprites?
Why not simply disable the behind buttons when adding new cards? Hollywood has the commands DisableButton() and EnableButton() for that. No need to remake all buttons...
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

[22 Jul 2006] Re: Overlapping Buttons

Post by NathanH »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 13:52:54 -0600

Hi,

Thanks, but perhaps there is a misunderstanding. If I disable the buttons there is no way to select cards that are partially visible behind the top card. Rather than that I guess I'll try layers. I'm hoping that overlapping buttons on layers will work the way I envision. Thanks.

Nathan
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

[22 Jul 2006] Re: Overlapping Buttons

Post by NathanH »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 15:14:51 -0600

Hi,

Oh well, buttons work the same way with layers. I'm sure I'll figure something out. I guess that I intuitively figured that when I load a new graphic it is placed on the top of whatever was there originally so buttons would work the same way. Placing new buttons and having them go behind existing buttons is just hard to reconcile with their layered on-screen graphics being placed oppositely. Perhaps a new button type "#NEWONTOPBUTTON" or a better-quality brain on my part :o)

Nathan
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[22 Jul 2006] Re: Overlapping Buttons

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 23:59:36 +0200
Hi,

Oh well, buttons work the same way with layers.
Yes. The button library does not care whether you use layers, sprites, etc.
I'm sure I'll figure something out. I guess that I intuitively figured that when I load a new graphic it is placed on the top of whatever was there originally so buttons would work the same way. Placing new buttons and having them go behind existing buttons is just hard to reconcile with their layered on-screen graphics being placed oppositely. Perhaps a new button type "#NEWONTOPBUTTON" or a better-quality brain on my part :o)
Here's an idea:

You could install a single button that covers the whole screen. Now when that button gets clicked, you traverse through an array containing the coordinates and dimensions of all cards on display. You can then use the Collision() function to check if the mouse pointer position collides with one of the cards.
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

[22 Jul 2006] Re: Overlapping Buttons

Post by NathanH »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Jul 2006 19:02:27 -0600

Hi,

Thanks! Yes, that will essentially create my own button creating mechanism.

Nathan
Locked