Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Privateer Puddin' on Mon 18/02/2019 05:29:58

Title: Grid of different hotspots/labels? Labels for books in bookcase
Post by: Privateer Puddin' on Mon 18/02/2019 05:29:58
Hi,

I have a bookcase where I want to display a 'different' (random from a short list) label for each book. Rather than drawing out multiple hotspots / gui labels etc, is there a way to generate a 'grid' over the graphics and then show a different piece of text when the mouse moves from one cell/book to another?

(http://tom-simpson.com/Library_BookCase1.png)

Thanks!

Title: Re: Grid of different hotspots/labels? Labels for books in bookcase
Post by: ManicMatt on Mon 18/02/2019 08:22:10
How about using mouse x/y coordinates in some way? Would that work?

Title: Re: Grid of different hotspots/labels? Labels for books in bookcase
Post by: Privateer Puddin' on Mon 18/02/2019 08:23:57
Quote from: ManicMatt on Mon 18/02/2019 08:22:10
How about using mouse x/y coordinates in some way? Would that work?



Yes, I had thought of a way that would involve a lot of if / else statements to check the mouse co-ordinate, but I'm sure there's a better way.
Title: Re: Grid of different hotspots/labels? Labels for books in bookcase
Post by: ManicMatt on Mon 18/02/2019 08:29:47
im not sure if the books are too close together but what about importing an object that is just the books with pixel spaces in between and then you set it to randomise what the description is. Although if they went back to the previous book it would be different again..

i think i might be on to something though.
Title: Re: Grid of different hotspots/labels? Labels for books in bookcase
Post by: Khris on Mon 18/02/2019 08:54:37
Grab the x and y of the mouse and subtract the top left corner.
Now divide both coordinates by a book's width / shelve height to get Book/Shelve coordinates.
Finally, multiply y by the number of books per shelve, then add x to get a unique index i for every book.
No if/else required.
Title: Re: Grid of different hotspots/labels? Labels for books in bookcase
Post by: Privateer Puddin' on Tue 19/02/2019 03:21:19
Quote from: Khris on Mon 18/02/2019 08:54:37
Grab the x and y of the mouse and subtract the top left corner.
Now divide both coordinates by a book's width / shelve height to get Book/Shelve coordinates.
Finally, multiply y by the number of books per shelve, then add x to get a unique index i for every book.
No if/else required.

Thanks Khris, got it!