realbasic-games
[Top] [All Lists]

Re: How to find a Group3D in a RB3DSpace

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: How to find a Group3D in a RB3DSpace
From: KamaShin <kamashin at free dot fr>
Date: Fri, 18 Feb 2005 21:55:16 +0100
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050218180023 dot 3F738735571 at lists dot realsoftware dot com>
I havn't read the topic from the beginning but according to my own experience, the best thing to do to find an object in an array is to have an ID property (an ID is a unique number delivered to any new object when it is created) since you re using your own subclass of Group3D, just add an integer call ID and have a global that would keep track of what was the last ID you assigned, this would give something like this:

(Have a global integer called for example LastID)
when creating your Group3D:

------------------------------------------------------------
Dim m As New MyObject

'fill m with what you need

m.ID = LastID
LastID = LastID + 1
m.Object3D.Append ACloneOfTheObject
------------------------------------------------------------
'Then, when looking for your object, your code would become something like this

Dim which as Object3D
Dim i as integer

which = me.FindObject(x,y)
if which = nil then return

for i = 0 to NumMyObjects
        if MyObjectsArray(i).ID=which.ID then exit
next

if i = NumShips+1 then Return

The objective is to clone the Object3D that is shown in your RBSpace but not the Group3D itself (which might not be possible in fact) So in the end, the objects contained in your Group3D (MyObject in fact) are clones from another one, but the id's of your MyObject is unique...

(Hope this is easy to understand and that it solves your problem)


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