Problem with Imagecollide.

Blitz3D Forums/Blitz3D Programming/Problem with Imagecollide.

Newbie31(Posted 2013) [#1]
Heyo,

I have been encountering a problem with "imagecollide".
Basically it goes like this. I have made game the aim is to destroy bricks on a wall. to begin a start menu loads and gives the player an option of which level to play. If level one is selected then there a 2bricks to destroy,(wall1_chunk1, wall1_pieces% = 1) and (wall2_chunk1, wall2_pieces%=1). If the player selects level two then there are 4bricks to destroy, (wall1_chunk1, wall1_chunk2, wall1_pieces% = 2) and (wall2_chunk1, wall2_chunk2, wall2_pieces%=2). right up to level 10.

However when I select a level and attempt to destroy a brick , I get the error "Object does not exist" in the section that checks the wall2_chunks. The objects are all drawn fine so clearly they exist. SO I decided to try and find the error by separating the code in too 2 files one that only does wall1_chunks and one that only does wall2_chunks. The problem is that when the code is separated they both work perfectly. I've been through the code and I can't find the problem. SO I thought maybe one of the gurus here could have glance and tell me what I've obviously done wrong?

Complete Files: :http://d01.megashares.com/dl/0o8GOJv/Wall_Bricks_V_0.1 - [IDEal] [REBUILD].rar
(I don't have megashares account so the file will probably be deleted after a couple of days)

Edit: I tried using codebox but my connection isn't so hot and it didn't post.


Yasha(Posted 2013) [#2]
The "Object does not exist" error message doesn't refer to visible, on-screen objects. It means that you tried to dereference Null, i.e. that a variable that should have held an instance of a custom type variable - an object - actually has the value Null, and thus field accesses through that variable are not valid.

So somewhere in your program, something is passing Null to a piece of code that expects a non-Null value. Follow the logic back from the point where you get the message and see where the value comes from, and whether it's being appropriately set (is there a branch in your function that lets the logic bypass the point where a value is assigned? Perhaps you're declaring the variable inside one If block and using it afterwards?); or if it comes from "outside" (from some other section of the code not guaranteed to return something specific), checked for Null before use, etc.


Guy Fawkes(Posted 2013) [#3]
If my.type <> Null ;)


Newbie31(Posted 2013) [#4]
Heyo,

Thanks for the advice, I went over my code I'm still not exactly sure what caused the problem, but I moved some of my functions like you suggested to be sure they are all getting the required values and it works now. I didn't know I could do that with types, but lesson learned.