 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
J_Taylor The Self-Proclaimed King of Ketchup

Joined: 02 Dec 2009 Posts: 188 Location: Western NY
|
Posted: Thu Dec 23, 2010 4:02 pm Post subject: Mouse compatibility Pt. 2 |
|
|
Okay, so due to a previous post a while ago, I got basic in-game mouse compatibility down pat. Unfortunately, now I'm looking for a bit more than just a mouse moving around. I've got the program to read that there's a mouse slice on top of a button slice, and then to do something if it is... but now I've got a problem of having only one button bein' checked. I put in two buttons, and two checks, and it only checks the second button. I hide the second check using the # key, and it check the first button.
I need four buttons for the main menu. Help? Here's my script. What'm I doing wrong?
Code: | include, plotscr.hsd
include, Alliance.hsi
#==============================================
global variable (0, mouse cursor)
global variable (1, new_game)
global variable (2, load_game)
global variable (3, options)
global variable (4, quit_but)
define constant (0, timer:mouse)
#==============================================
plotscript, start_game, begin
init mouse
mouse region (-1, -1, -1, -1)
mouse cursor := load walkabout sprite (1)
main_menu
end
#==============================================
script, main_menu, begin
new_game := create rect (110, 30)
load_game := create rect (110, 30)
# options := create rect (110, 30)
# quit_but := create rect (110, 30)
put slice (new_game, 110, 60)
put slice (load_game, 110, 90)
# put slice (options, 110, 120)
# put slice (quit_but, 110, 150)
set slice visible (new_game, off)
set slice visible (load_game, off)
# set slice visible (options, off)
# set slice visible (quit_but, off)
mainmenu mouse update loop
end
#==============================================
script, mainmenu mouse update loop, begin
set slice x (mouse cursor, mouse pixel x)
set slice y (mouse cursor, mouse pixel y)
slice to front (mouse cursor)
if (slice contains (new_game, mouse cursor)) then (replace walkabout sprite (mouse cursor, 2)) else (replace walkabout sprite (mouse cursor, 1))
if (slice contains (load_game, mouse cursor)) then (replace walkabout sprite (mouse cursor, 2)) else (replace walkabout sprite (mouse cursor, 1))
set timer (timer:mouse, 0, 1, @mainmenu mouse update loop)
end |
_________________ Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%
See a pattern forming? I do, dammit. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Dec 23, 2010 5:35 pm Post subject: |
|
|
That's because the 'else' of the second check restores the mouse cursor to its default sprite if it isn't on the second button. Try the following instead:
Code: | variable (cursor sprite)
cursor sprite := 1 # default
if (slice contains (new_game, mouse cursor)) then (cursor sprite := 2)
if (slice contains (load_game, mouse cursor)) then (cursor sprite := 2)
replace walkabout sprite (mouse cursor, cursor sprite)
|
Also, are you sure you want to use 'slice contains'? That'll only register the cursor as being over a button if it is completely over it. I suggest trying 'slice collide point' instead:
Code: | if (slice collide point (new_game, mouse pixel x, mouse pixel y) then (cursor sprite := 2) |
Another tip: if you're using nightlies, you can create a set of slices in the Slice Collection Editor in Custom, and load them using 'load slice collection' instead of creating and positioning them all via script _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
J_Taylor The Self-Proclaimed King of Ketchup

Joined: 02 Dec 2009 Posts: 188 Location: Western NY
|
Posted: Thu Dec 30, 2010 7:22 am Post subject: |
|
|
Okay, but will the cursor sprite change BACK to the default once the mouse is not over the button? I'd try inputing this right now, but I don't have an awful lot of time online, so I'll just do it later.
I'm sure I want to use "slice contains". I tried the two of them back and forth for a while, trying to decide, but I just ended up lengthening the height and length, and it fits just fine.
Also, um... I've given the nightly a try; I've tried a few things in it, but I'm not really sure how it works... _________________ Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%
See a pattern forming? I do, dammit. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Jan 01, 2011 7:23 am Post subject: |
|
|
J_Taylor wrote: | Okay, but will the cursor sprite change BACK to the default once the mouse is not over the button? |
Yes, that's what the "cursor sprite := 1 # default " is for.
Quote: | Also, um... I've given the nightly a try; I've tried a few things in it, but I'm not really sure how it works... |
You mean you've tried the Slice Collection Editor and didn't really understand it? Some of the slice options are pretty complex, but you ignore nearly everything at first (also, realise that a many of the menu items have individual help pages). There's lots of info at 'Plotslices Tutorial', and you can look through the slice collections in Hamster Math for some examples. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
J_Taylor The Self-Proclaimed King of Ketchup

Joined: 02 Dec 2009 Posts: 188 Location: Western NY
|
Posted: Mon Jan 03, 2011 8:22 am Post subject: |
|
|
Okay. Thanks! _________________ Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%
See a pattern forming? I do, dammit. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|