Results 1 to 2 of 2

Thread: Detect Click on Image

  1. #1
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Detect Click on Image

    I have an image (stored in a TDXImageList) that is displayed on the screen over my Map. This image is used to display the game state (selected units, orders, small map etc).

    When the mouse is clicked on the screen how do I know if the mouse was clicked over a non-transparent portion of this image?

    I have the Top,Left of the Image and the X,Y of the click, how do I know if the pixel of the image at that X,Y is transparent?

    I need this to know when to pass the click through to the Map component of capture it in the game state component.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  2. #2

    Detect Click on Image

    There are two solutions I know for your problem. The first is with a mask (monochrome bitmap black&white) where you can check the transparent and non-transparent areas and check whether the mouse clicked a transparent or non-transparent pixel. This can also be done with a pixel-perfect collision table/array.

    The second method is to use the pixel array (not sure if you can access that easily from DelphiX's DXImageList, but I think it's possible) and to check wheter the pixel that the mouse clicked on has the same colour as the transparent color if so then the user clicked on a transparent pixel otherwise the user clicked on a non-transparent pixel!
    Do it by the book, but be the author!
    <br />
    <br />Visit the Lion Productions website at:
    <br />http://lionprod.f2o.org

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •