Space Shooter Error Thread

I'm working on the space shooter kit, and thought I'll tackle this problem first. The main problem is whenever the player runs out of lives I get the following error message.

Error in draw for behaviorHealth Monitor HUD
TypeError
Error #1009: Cannot access a property or method of a null object reference.
	
at scripts::Design_117_117/draw()[C:UsersMatthewDownloadsStencylsandboxflashscriptsDesign_117_117.as:44]
	
at stencyl.api.engine.behavior::Behavior/draw()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/behavior/Behavior.as:211]
	
at stencyl.api.engine.behavior::BehaviorManager/draw()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/behavior/BehaviorManager.as:165]
	
at stencyl.api.engine.behavior::BehaviorManager/postDraw()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/behavior/BehaviorManager.as:142]
	
at stencyl.api.engine::GameState/render()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/GameState.as:1487]
	
at org.flixel::FlxGame/update()[/Users/jon/Desktop/stencyl/plaf/flash/flixel/org/flixel/FlxGame.as:373]


I don't know what causes it, but it would be nice to have it fixed. Here's the behavior.

« Last Edit: May 05, 2011, 07:10:19 am by blackbishop89 »

Epic428

  • Posts: 1118
I would first move the "For each actor of type..." wrapper to the "When Created" wrapper. See if that solves the problem

my guess is it is setting the actor null at some point, and for some reason isn't allowing it to operate properly.


Second, I would print out each of the values in "When Drawing" to see what value is coming up null. Remember, they will be your best friend, those print statements.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Ceric

  • *
  • Posts: 610
I tried moving the "For each actor of type..." block to When Created and it breaks the Behavior entirely. Also, printing out all the attributes doesn't help. None of them are set to null at any point until the Behavior itself breaks, at least based on the tests I just ran.


Ceric

  • *
  • Posts: 610
Seems like the periodic task is sending a message to the enemy actors, which are already dead, and is attempting to activate the Bullet Wave Behavior, but that doesn't make much sense.

Epic428

  • Posts: 1118
I am assuming based on what you've said, Ceric, that this behavior is attached to multiple actors, correct, or is it a scene behavior?

Unfortunately, I have not worked with this kit, so I was only suggesting based off the information available to me at the time, however, given its type it would explain why my suggestions would not work. If this is not solved by Friday, I will take a look to see if I can help solve it.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Ceric

  • *
  • Posts: 610
Health Monitor HUD is a scene Behavior that monitors the player actor.

The error I'm getting, however, isn't the same as the one Blackbishop is getting. The null object error I'm seeing refers to the Bullet Wave Behavior, which relies on the Do Periodically Behavior that sends a message to enemy actors that have the Bullet Wave Behavior attached.

If you do have time to help, great. If not, I'll keep looking into it.

Epic428

  • Posts: 1118
Ah well, I will be going to bed in a few minutes after I watch some "Rocko's Modern Life" on Netflix. I can certainly take a look into this tomorrow after I wake up and see if there isn't anything I can find causing the problem.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Ceric

  • *
  • Posts: 610
I did some more testing on this. First, the Do Periodically Behavior needs to have a check that cancels the periodic task added at the top.

Second, the null object error is only showing up (for me, at least), when the player actor loses all 3 lives and the game restarts. Up until that point, the console isn't showing any errors.

Hope that helps. I'll keep looking into this, too.

Epic428

  • Posts: 1118
Here this is the fix for the Monitor Health HUD behavior.

I tested several times and never received the 1009 error.

Edit: to Clarify, you have to check if the attribute has value first otherwise if it doesn't then it will still show up null when it checks if it is alive. It also should be nested so it doesn't run the rest when it comes back false.

Also fixing the same code in the always behavior allowed me to only set the attribute one time in the when created block, as the code beneath would not run, therefore not display error.

« Last Edit: May 05, 2011, 03:19:44 pm by Epic428 »
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Epic428

  • Posts: 1118
I'm about to watch some Idol, but I will take a look at this afterward to see what else seems to be causing your problems.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Greg

  • *
  • Posts: 1260
What are the steps to reproduce the error blackbishop?  I downloaded your zip file and when I run the game, all I get is a scrolling error message across the screen:

Warning: Behavior does not exist - Auto Scroll Vertical Scrolling
Warning: Behavior does not exist - Auto Scroll Vertical Scrolling
Warning: Behavior does not exist - Auto Scroll Vertical Scrolling

Epic428

  • Posts: 1118
I tried multiple times and was unable to reproduce the error, but I suppose I was not hitting it at the right time. Anyway, I know why it would cause the error. You want to utilize the same value checks. In fact, this should be done almost every time you reference an actor.

Code: [Select]
if( self has value )
{
    if( self is alive)
    {
        tell self [....]
     }
}

There is a possibility, that the space bar is being pressed within the same frame that the actor is being killed. While it is not actually killed until the next update (next frame) its value is most likely set to null that frame. This means that it cannot send the message, therefore resulting in the error.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Ceric

  • *
  • Posts: 610
Quote
Also I'm attaching a zip of the current kit for you guys to test out. Some changes, have been made that most likely resulted in this error.

EDIT: We need to make sure all attributes (both hidden and non hidden) that are not obvious to what they're purpose is have descriptions. Any takers to help with that task?

EDIT2: Another thing, we need to fix the 4 way movement for auto scrolling behavior so it works regardless of the direction the screen scrolls since it's now possible to make it scroll in any direction.

EDIT3: Another thing. The health of the player doesn't appear until you lose a life. This also needs to be fixed.

What changes do you think caused these errors? None of them were appearing before, just the null object error for the Health Monitor HUD Behavior.

Ceric

  • *
  • Posts: 610
Just tried the new version of Health Monitor HUD and got the same errors that Blackbishop was reporting. I feel like we're all missing something obvious here but can't figure out what it is...

Ceric

  • *
  • Posts: 610
For some reason (maybe I'm doing something wrong here, but I'm not sure what), to get the health to display, you have to set the attribute Actor to Monitor to "the actor" in the "always" block. If you do it in the When Created block, the Behavior won't work. Here's a screenshot: