Android Question end class instance (from within)

Marc De Loose

Licensed User
lets say i have a sub in main
sub a
        Dim theGauge As Gauge

end sub
and a body delegate class(XUI2D) that has something like this in it
public Sub Initialize (TheX2 As X2Utils,actorName As String,thePos As B2Vec2,theID As Int,theIndex As Int)
    GaugeBaseName    = actorName
    thePosition        = thePos
    coupledID         = theID
    coupledIndex    = theIndex
    uniqueId        = DateTime.Now
End Sub

that gets initialised with sub a a couple of times. So sub A gets called x amount of times.
This creates new instances and they all work autonomously and seperate from eachother.
That part works great.

The thing is when the instance becomes obsolete it knows it and need to be destroyed... ended deinitialised or whatever
I dont keep theGauge class variable anywhere (or i would rather not as there is no point)

So can the class instance dinitialize itself when needed from within itself like (me.finish)?

thx for even reading this :)
Last edited:

Marc De Loose

Licensed User
After some thought is this not enough? (the simple Return statement)

Public Sub Tick (GS As X2GameStep)
    If GS.ShouldDraw Then
        If DragMode=False Then
        End If
    end if
    if myWorkIsDone then
    end if
End Sub


Staff member
Licensed User
You posted a general question about classes. The answer is that you don't need to do anything special. The class instance will be released once there are no live references to that instance.

If you have a specific question about a class instance usage in XUI2D then it is better to post in the game forum and provide more information about the class.