Results 1 to 6 of 6

Thread: have the hint property on a sprite

  1. #1

    have the hint property on a sprite

    on the project i'm working on, a cards game, i need the hint property for the cards.
    which is the easy/best way to have it using delphix for graphics?

    another question: how i can handle the right mouse button?
    Will: "Before you learn how to cook a fish you must first learn how to catch a fish." coolest

  2. #2

    have the hint property on a sprite

    TO handle the right mouse button

    in your DXDraw1MouseDown event
    [pascal]

    procedure TfrmGuns.DXDraw1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin

    if Button = mbRight then
    begin

    // Do stuff with right mouse button.

    end;

    end;
    [/pascal]


    What do you mean by hint property?
    Can you explain in a little more detail? Do you mean a tooltip kind of thing?

  3. #3

    have the hint property on a sprite

    ty for the answer

    for example: if you put a button in a form you can set its "showhint" property and type some text in the "hint" variable, so when the mouse is over the button you should see the text you typed. (excuse me for my bad english .P )
    Will: "Before you learn how to cook a fish you must first learn how to catch a fish." coolest

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    have the hint property on a sprite

    You're gonna have to manage it all by yourself, but it's not that hard.

    1) first detect if the mouse cursor is over the sprite
    2) draw the hint box frame
    3) draw the corresponding text for the sprite that has been detected

    done!

    Basically it's all in knowing where your mouse is. And to do that use TForm.OnMouseMove(); if your game is in a windows 'form'. There may be another one for the TDXDraw object, but I don't have Delphi on this system so I cannot check right now.

    The event call will look like this:
    [pascal]procedure TMain.MapScreenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);[/pascal]

    You're interested in X and Y. Thats your mouse cursor's location within the screen.

    Now create 2 Integers CursorX and CursorY [size=9px](or use a TPoint, but if you don't have to add a whole new unit to your uses clause why bother.)[/size] and assign the mouse cursor values to those in the OnMouseMove procedure. Then when you draw all your sprites and other UI stuff, draw your hint boxes there based off of your CursorX, CursorY values.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    have the hint property on a sprite

    ty will,

    it is a possibility but i have to check something like Z position because i can have cards over others cards and so on...
    i don't know if is better take a component that have this property just implemented and work over it or manage it like you say.

    so, related to this i have a question: if i create a delphix app with a button that have the hint property, when i move the mouse over it i can see the hint's text. This text is printed using directx or windows API?
    I think the 2nd one.
    Will: "Before you learn how to cook a fish you must first learn how to catch a fish." coolest

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    have the hint property on a sprite

    The GDI [size=9px](iow yes, the WinAPI)[/size]

    Which is to say that the only thing that is using DirectDraw is the TDDraw overlay component. All else is much like a normal Windows app which used the GDI or WinAPI to draw all your forms and components.

    Putting the hint depends all on how you want your layout, you can try to work something outside of the constraints of the TDXDraw 'overlay', but you may get artifacts and you'll have to devise something with the components you have OR you'll have to use the canvas, which I'm not 100% sure will draw over a TDXDraw component? Can someone verify that last one for me?


    Another possible option, if you are using either a standard TForm or TDXForm for your game [size=9px](either will work)[/size], you can add a status bar and just place your hints in there?
    Jason McMillen
    Pascal Game Development
    Co-Founder





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
  •