Collectible Collision Error

JAPrice

  • Posts: 5
Okay, I have another problem with the tutorials in the book. This applies to making the collectible objects fade out (and later, shrink and disappear) when the monkey collides with them. I followed the tutorials exactly and even opened up the game files supplied with the book, but every time I make the monkey pick up any collectible, the game returns an error saying "TypeError: Error #1009: Cannot access a property or method of a null object reference." This happens both with fade out and shrinking and, as I stated, even the pre-made Stencyl files I downloaded reproduced this error. Is there some problem with that particular instruction?

I was able to move past it by simply giving up on making the collectibles play any special effects over time when collected and simply making them disappear, but I would like to know if there's a different or better way to make the special effects work.

Attaching my personal tutorial-following file for reference (I made my level a bit larger than the book's design).

ChoochioGames

  • Posts: 7
I am having the same problem. 

I've tried a number of things and it seems to only happen when "kill actor of group" is within "do after x seconds".

I would like to know the correct way to do this and why it has to be done differently on the collectibles vs. the statues.  Hopefully Innes has some insight. 

Btw, I am using Stencyl version 2.2. 

Thanks,
Eric

JAPrice

  • Posts: 5
I found a fix. Seems necessary to add a check to actually ask if the fruit is still 'alive' before it's 'killed'. In retrospect, it makes perfect sense: prevents the program from triggering the kill command too soon (which creates the null reference error). Attached is an image of how I coded it.

ChoochioGames

  • Posts: 7
Thank you!  I appreciate it.  This worked for me.

ChoochioGames

  • Posts: 7
I also had had to do the same thing to kill the monkey actor after the countdown expired.  I wonder if that is just a version 2.2 thing or if it will be that way in 3.0 as well.

Innes

  • *
  • Posts: 1963
Thanks for your input on this discussion; I'm glad you solved the problem.

It's generally best-practice to check that an actor is alive before killing it, and this is also true in 3.0
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

firefaxx

  • Posts: 2
Thank you Innes for an exxelent book with great explanations and examples to follow.
Bought it just minutes after downloading stencyl  :)

But I'm having the same problem (v2.2) with this fade-out lesson too. I tried to follow the book and tried the downloaded code but flashplayer crashes everytime  :'(
Did the problem occured of some unexpected change in the update of Flashplayer since this book was published?

Since this book is aimed for newbies like me, I really dont understand the code and the solution here.
The solution (thanks to JAPrice) seems way to complicated for a beginner at this point of time in the book where you just learned the basics of custom behaviors...
Just copying the solution does not help me to understand or learn from it.

Can you please help me out so I can continue the reading and follow the booktutorials?



« Last Edit: January 10, 2014, 06:50:07 am by firefaxx »