LIST populated, or not?

sterlingy

Active Member
Licensed User
Longtime User
I created a list and added an object to it. If I print the contents of the list to the log, I get all kinds of data. If I try to retrieve the first and only object in the list, it returns nothing.

B4X:
   leroyCollisionlist.Initialize
   leroyCollisionlist.Add(game.MyLeroy)
Log("clcLen: " & leroyCollisionlist.Size)   
'Log("lBD: "& game.MyLeroy)
Log("lArray: " & leroyCollisionlist)
   leroyCollision.Initialize(bd.DestRect, leroyCollisionlist, 10, 300, 10 * GameUtils.scale, objType)
Log("lCl: " & leroyCollisionlist.Get(0))

Form the log:

Installing file.
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
scale: 2.5062499046325684
clcLen: 1
lArray: (ArrayList) [[animator=[srcrects=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@4156c1e0, bitmaps=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper;@41555b88, gameutils=null
, main=null, index=0, interval=0
, height=125, animationinterval=10, vx=0
, vy=0, width=125], bd=Src: (Rect) Not initialized, Dest: (Rect) Not initialized, Bitmap: (Bitmap) Not initialized, Delete: false, carcollision=[outrect=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@4155a978, gameutils=null, others=(ArrayList) []
, main=null, myrect=(Rect)(776, 602, 901, 727), objecttype=car
, interval=0, checkinterval=10, safezonex=10
, safezoney=0]
, collision=[outrect=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@41559b60, gameutils=null, others=(ArrayList) [[animator=[srcrects=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@427bce58, bitmaps=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper;@427bcfb0, gameutils=null
, main=null, index=0, interval=0
, height=125, animationinterval=10, vx=0
, vy=0, width=50], bd=Src: (Rect)(0, 240, 80, 480), Dest: (Rect)(427, 456, 477, 581), Bitmap: (Bitmap): 480 x 480, Delete: false, pooprect=(Rect) Not initialized
, game=[worldmap=[[Lb4a.example.gamemanager$_blockunittype;@4156c978, visbmd=(MyPanel): Layout not available, tscore=(TextView): Left=480, Top=580, Width=304, Height=120, Text=$000463
, tpoops=(TextView): Left=584, Top=713, Width=304, Height=120, Text=0135, tlevel=(TextView): Left=0, Top=0, Width=800, Height=1205, Text=01, threesectimer=anywheresoftware.b4a.objects.Timer@415879f0
, tempgv=(MyPanel): Layout not available, blockcbmp=(Bitmap) Not initialized, blockdbmp=(Bitmap) Not initialized
, blockebmp=(Bitmap) Not initialized, blockfbmp=(Bitmap) Not initialized, tdogs=(TextView): Left=584, Top=836, Width=304, Height=120, Text=0233
, blockxbmp=(Bitmap) Not initialized, bloctypelist=[Lb4a.example.gamemanager$_blockunittype;@4156c790, cars=(ArrayList) []
, carsbitmaps=[[Lanywheresoftware.b4a.objects.GameViewWrapper$BitmapData;@41554ee0, streetbackground=Src: (Rect)(0, 0, 512, 747), Dest: (Rect)(0, 96, 800, 843), Bitmap: (Bitmap): 512 x 2048, Delete: false, sounds=(SoundPool) android.media.SoundPool@42759e88
, shovels03bmp=(Bitmap): 218 x 123, shovels02bmp=(Bitmap): 218 x 123, dogs=(ArrayList) [[animator=[srcrects=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@427bce58, bitmaps=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper;@427bcfb0, gameutils=null
, main=null, index=0, interval=0
, height=125, animationinterval=10, vx=0
, vy=0, width=50], bd=Src: (Rect)(0, 240, 80, 480), Dest: (Rect)(427, 456, 477, 581), Bitmap: (Bitmap): 480 x 480, Delete: false, pooprect=(Rect) Not initialized
, game=[worldmap=[[Lb4a.example.gamemanager$_blockunittype;@4156c978, visbmd=(MyPanel): Layout not available, tscore=(TextView): Left=480, Top=580, Width=304, Height=120, Text=$000463
, tpoops=(TextView): Left=584, Top=713, Width=304, Height=120, Text=0135, tlevel=(TextView): Left=0, Top=0, Width=800, Height=1205, Text=01, threesectimer=anywheresoftware.b4a.objects.Timer@415879f0
, tempgv=(MyPanel): Layout not available, blockcbmp=(Bitmap) Not initialized, blockdbmp=(Bitmap) Not initialized
, blockebmp=(Bitmap) Not initialized, blockfbmp=(Bitmap) Not initialized, tdogs=(TextView): Left=584, Top=836, Width=304, Height=120, Text=0233
, blockxbmp=(Bitmap) Not initialized, bloctypelist=[Lb4a.example.gamemanager$_blockunittype;@4156c790, cars=(ArrayList) []
, carsbitmaps=[[Lanywheresoftware.b4a.objects.GameViewWrapper$BitmapData;@41554ee0, streetbackground=Src: (Rect)(0, 0, 512, 747), Dest: (Rect)(0, 96, 800, 843), Bitmap: (Bitmap): 512 x 2048, Delete: false, sounds=(SoundPool) android.media.SoundPool@42759e88
, shovels03bmp=(Bitmap): 218 x 123, shovels02bmp=(Bitmap): 218 x 123, dogs=(ArrayList) [[animator=[srcrects=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$RectWrapper;@427bce58, bitmaps=[Lanywheresoftware.b4a.objects.drawable.CanvasWrapper$Bitm
[B]lCl: [/B]

** Activity (main) Resume **

---------------------

If you wonder why I need a list with one object, it because I need to to be compatible with what is passed to the collision module. All the other entities in the game are lists of multiple objects.

-Sterling
 

eps

Expert
Licensed User
Longtime User
Hi

It's not something silly like you have to assign the value to a variable and then you can use it in the log statement is it? Something along those lines rings a bell.

Of course if you've got the debugger working and are using it you should be able to see the variables created, as a sense check, as opposed to using log.
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
The reason I use the log is that I can see the variables in real time as the code runs. Sometimes there are situations, where it would take forever to step through to the point you need to check the variables. Either that, or I am using it the wrong way.

-Sterling
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
Problem solved. The data type was a reference to a class that was missing a subroutine that the collision detector required.

I suppose it pays to read the fine print.

-Sterling
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…