PDA

View Full Version : have the hint property on a sprite



Paizo
02-01-2007, 10:51 AM
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?

jasonf
02-01-2007, 11:25 AM
TO handle the right mouse button

in your DXDraw1MouseDown event


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;



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

Paizo
02-01-2007, 11:35 AM
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
02-01-2007, 05:24 PM
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:
procedure TMain.MapScreenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

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

Now create 2 Integers CursorX and CursorY (or use a TPoint, but if you don't have to add a whole new unit to your uses clause why bother.) 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.

Paizo
03-01-2007, 10:26 AM
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
03-01-2007, 03:14 PM
The GDI :) (iow yes, the WinAPI)

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 (either will work), you can add a status bar and just place your hints in there?