realbasic-games
[Top] [All Lists]

Re: object subclasses doing their own thing

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: object subclasses doing their own thing
From: Lars Jensen <larsjensen at rcn dot com>
Date: Sat, 26 Jun 2004 04:06:44 -0400
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>
> If the logic in ShotObject.nextframe does decide to do
> GameObject.nextframe, how does it make that happen? I mean how do I tell
> it to pass the .nextframe call on up the chain to its super's .nextFrame?

Like this:

  Sub NextFrame // (method of ShotObject)
     [Do some stuff...]
     Super.nextFrame
  End Sub

"Super" is a keyword meaning "my superclass". Alternately, you could say:

  Sub NextFrame // (method of ShotObject)
     [Do some stuff...]
     GameObject.nextFrame
  End Sub

but Super is better, because you might someday change the name of
GameObject, or insert another class between GameObject and ShotObject, and
with Super, the code doesn't have to change.

I've put the nextFrame call at the bottom in these examples, but it could be
at the top as well, it's totally a matter of what makes sense given your
situation.

lj

_______________________________________________
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>