realbasic-games
[Top] [All Lists]

Re: Question regarding class / subclass

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Question regarding class / subclass
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Wed, 23 Jun 2004 13:35:57 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
List-help: <mailto:realbasic-games-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Games <realbasic-games.lists.realsoftware.com>
List-post: <mailto:realbasic-games@lists.realsoftware.com>
References: <E7690953-C541-11D8-96A8-000A957887E6 at goodlearning dot com>
At 1:19 PM -0500 6/23/04, Paul Kaiser wrote:

This may seem like a sophomoric question

There are no sophomoric questions, only sophomoric answers.  :)

I have various objects that are subclasses of Object3D. For example:
Shot
Skeleton
TrashCan

I'd like for every one of these objects to have a unique identifier (integer) within the game. My thought was to have an array "objArray as Object3D" and that I can members of this array can reference the various instances of Object3D subclasses.

That'll work. (You'll probably want to define a base class to all of the above -- I usually call it GameObj -- whose super is Object3D, and which defines things like GetID.)

i.e. objArray indices:
0 - 8 reference player shots (a maximum of 9 available at any given time)
9 - 59 reference skeletons (50 max)
60 - 70 reference trashcans (10 max)

I'm not sure this is the way I'd go about it, but it will work.

Can I declare the array to be of type "Object3D" and have it reference various subclasses of Object3D?

Yes. A reference (including an array) of type Object3D can store anything that IsA Object3D. An instance of an Object3D subclass IsA Object3D, and so will work just fine.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

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

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