Greetings.
I'm having a problem; storing a data type in an object tag returns unusual values.
When I click on either tile object, the click event will have the "SwapType" variable values as:
tileSwap.xSource = 2
tileSwap.ySource = 2
tileSwap.xTarget = 2
tileSwap.yTarget = 2
When the intention is to retrieve the first set of values from the first Tile click and the second set of values from the second Tile click.
Am I doing something wrong here?
Thanks in advance.
Here's the code:
------- Main Body -------
Sub Process Globals
Type SwapType(xSource As Int, ySource As Int, xTarget As Int, yTarget As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim tileSwap As SwapType
Dim xTiles(2) as Tiles
Activity.Initialize("")
tileSwap.xSource = 1
tileSwap.ySource = 1
tileSwap.xTarget = 1
tileSwap.yTarget = 1
xLoc = 100 : yLoc = 100
xDim = 150 : yDim = 150
xTiles(0).Initialize
xTiles(0).setObj(Activity, xLoc, yLoc, xDim, yDim)
xTiles(0).setTag(tileSwap)
tileSwap.xSource = 2
tileSwap.ySource = 2
tileSwap.xTarget = 2
tileSwap.yTarget = 2
xLoc = 300 : yLoc = 300
xDim = 150 : yDim = 150
xTiles(1).Initialize
xTiles(1).setObj(Activity, xLoc, yLoc, xDim, yDim)
xTiles(1).setTag(tileSwap)
End Sub
------- Class Tiles -------
Public Sub setObj(ActivityView As Activity, xLoc As Int, yLoc As Int, xDim As Int, yDim As Int)
Dim TileObj As Label
TileObj.Initialize("Tile")
ActivityView.AddView(TileObj, xLoc, yLoc, xDim, yDim)
End Sub
Public Sub setTag(sType As SwapType)
TileObj.Tag = sType
End Sub
Private Sub Tile_Click()
Dim TileSwap As SwapType
Dim xtSource, ytSource as Int
Dim xtTarget, ytTarget as Int
TileSwap = TileObj.Tag
xtSource = TileSwap.xSource
ytSource = TileSwap.ySource
xtTarget = TileSwap.xTarget
ytTarget = TileSwap.yTarget
End Sub
I'm having a problem; storing a data type in an object tag returns unusual values.
When I click on either tile object, the click event will have the "SwapType" variable values as:
tileSwap.xSource = 2
tileSwap.ySource = 2
tileSwap.xTarget = 2
tileSwap.yTarget = 2
When the intention is to retrieve the first set of values from the first Tile click and the second set of values from the second Tile click.
Am I doing something wrong here?
Thanks in advance.
Here's the code:
------- Main Body -------
Sub Process Globals
Type SwapType(xSource As Int, ySource As Int, xTarget As Int, yTarget As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim tileSwap As SwapType
Dim xTiles(2) as Tiles
Activity.Initialize("")
tileSwap.xSource = 1
tileSwap.ySource = 1
tileSwap.xTarget = 1
tileSwap.yTarget = 1
xLoc = 100 : yLoc = 100
xDim = 150 : yDim = 150
xTiles(0).Initialize
xTiles(0).setObj(Activity, xLoc, yLoc, xDim, yDim)
xTiles(0).setTag(tileSwap)
tileSwap.xSource = 2
tileSwap.ySource = 2
tileSwap.xTarget = 2
tileSwap.yTarget = 2
xLoc = 300 : yLoc = 300
xDim = 150 : yDim = 150
xTiles(1).Initialize
xTiles(1).setObj(Activity, xLoc, yLoc, xDim, yDim)
xTiles(1).setTag(tileSwap)
End Sub
------- Class Tiles -------
Public Sub setObj(ActivityView As Activity, xLoc As Int, yLoc As Int, xDim As Int, yDim As Int)
Dim TileObj As Label
TileObj.Initialize("Tile")
ActivityView.AddView(TileObj, xLoc, yLoc, xDim, yDim)
End Sub
Public Sub setTag(sType As SwapType)
TileObj.Tag = sType
End Sub
Private Sub Tile_Click()
Dim TileSwap As SwapType
Dim xtSource, ytSource as Int
Dim xtTarget, ytTarget as Int
TileSwap = TileObj.Tag
xtSource = TileSwap.xSource
ytSource = TileSwap.ySource
xtTarget = TileSwap.xTarget
ytTarget = TileSwap.yTarget
End Sub