Jibble

The AGS Awards ceremony will take place starting 20:00GMT on Saturday 30 March! Check out the thread for more details and to get the client.

Author Topic: Grid of different hotspots/labels? Labels for books in bookcase  (Read 126 times)

Privateer Puddin'

  • Mittens Knight
  • bob
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?



Thanks!


How about using mouse x/y coordinates in some way? Would that work?


Privateer Puddin'

  • Mittens Knight
  • bob
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.

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.

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
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.

Privateer Puddin'

  • Mittens Knight
  • bob
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!