2 Replies Latest reply on May 22, 2008 12:50 PM by 807591

    Attaching a String to an image

      Okay, what i've got going on is a tile array. The array is based on loading a 25x25 image, tiling it according to the array's length, and then drawing each tile to the screen. What I want, is to be able to move my mouse over the top of a tile and have it display a String, because I plan on having each type of tile have different options, such as dig or mine. I could easily do this if the tiles did not move. The problem is that they scroll as the character moves off of the screen. What options do i have to display a string as you mouse over the tile?
        • 1. Re: Attaching a String to an image
          You could use MouseListener's for detecting when you're over a tile. For the String part, you have several options. You could create a Map that translates tiles into Strings. You could make your Tiles a separate class, with a String variable, so when you detect which tile is hovered over you can simply get the variable from that specific tile.
          • 2. Re: Attaching a String to an image
            Yeah I assumed I could use MouseListeners, something along the lines of attaching a variable to each corner of each tile, just to get it's location on the screen. Then from there getting the numerical variable from the tile (only have 3 different tiles at the moment), then add a boolean to tell if I'm over the tile or not. I've been playing with that and haven't been about to see any results.