Hi, Not sure if this is still a newbie question. I have 2 types. One called Planet which orbits around a fixed point. Works ok. I have another type called satellite which I want to orbit around a planet. What I need help with is how do I pass the name of the planet type instance/object and then call its accessor methods from within the satellite type so I can have the satellite orbit around the centre of the planet.
Thanks
Does something like this do the sort of thing that you need? Or were you wanting to pass a name$ ("Terra" in this example) rather than an instance name (Earth in this example)?
Strict
Type Planet
Field Name:String
Method GetName:String()
Return Name
End Method
End Type
Type Satellite
Field Name:String
Method SetOrbit( p:Planet )
Print Name + " orbits " + p.GetName()
End Method
End Type
Local Earth:Planet = New Planet
Earth.Name = "Terra"
Local Moon:Satellite = New Satellite
Moon.Name = "Luna"
Moon.SetOrbit( Earth )
Nevermind, I'm a clod, just reread the previous post properly :P
About 30 minutes later I figured out something to try and I surprised myself and it actually worked.
Field orbitPlanet:Planet
Method SetSatelliteOrbit(p:Planet)
' record which planet to orbit
orbitPlanet = p
End Method
Method UpdateOrbitCentre()
orbitCentreX = orbitPlanet.getX()
orbitCentreY = orbitPlanet.getY()
End Method
Oh, maybe I'm not a clod, that's what I had.