realbasic-games
[Top] [All Lists]

Re: [Ann] Making a Card Game with Cards.dll

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: [Ann] Making a Card Game with Cards.dll
From: Aaron Ballman <aaron at realsoftware dot com>
Date: Wed, 16 Nov 2005 09:02:19 -0600
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <4379669E dot 3070301 at realsoftware dot com> <437AB283 dot 2040805 at ix dot netcom dot com> <437ABAE0 dot 5060307 at realsoftware dot com> <437B3367 dot 3080401 at ix dot netcom dot com>
OK. Let me see if I'm following this. If "g is a Graphics object, usually ... the one passed into the _Paint_ event for a Canvas or Window object" and "_Paint_ is an event that is called by the framework when it's time to repaint an item" and in that situation _Paint_ "gets passed a Graphics handle that all the drawing should happen on" and in those circumstances "you can take that Graphics object and use it when calling one of the _Draw_ methods," does that mean that you can only use one of the _Draw_ methods when a _Paint_ event for a Canvas or Window object has somehow been triggered (since that is that is "usually" how it is done)?

Not only -- you can get a Graphics object from a Picture for example, and draw directly into a Picture object. But ultimately, if you want this to show up on the screen, you should be doing it in the Paint event.

If so, how to you trigger the Paint event (if that's required in order to be able to use g in one of the Draw methods)? If not - i.e., if the Paint event is only the "usual" way to get a meaningful value for g as a passed parameter and not the "only" way - then how else can we (figuratively speaking) get a "handle" on g?

You can trigger a Paint event by calling Refresh on what you want painted (so you could call Canvas.Refresh, or Window.Refresh, etc).

Or, to put it yet another way, how does one accomplish the simple act of drawing a particular card face up at a particular location?

Put the following code in the Window.Paint event:

someCardObject.DrawFaceUp( g, 25, 25 )

That'll draw the card at 25, 25 (relative to the window's upper left of the client area).

HTH!

~Aaron
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>