Null pointer, error 1009

Tempus Vaito

  • Posts: 25
Alright, i've just recently solved an on going problem that has nothing to do with this and it's came out of nowhere. Nothing has changed since i last opened the game yesterday but today i am getting the error shown below. The error occurs when an enemy collides with the main player. I have searched through all my code to find any null pointers and there are non whatsoever. What's even more bizarre is that the problem occurs on every one of my scenes bar one scene. Not much changes from scene to scene so i have no idea where this error is coming from. It seems everytime i open Stencyl the day after a problem comes out of nowhere. If anyone has any idea that would be great thank you.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at MethodInfo-6760()[Source/scripts/ActorEvents_67.hx:92]
   at com.stencyl.models::Actor/innerUpdate()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/models/Actor.hx:1530]
   at com.stencyl::Engine/update()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2477]
   at com.stencyl::Engine/postUpdate()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2616]
   at com.stencyl::Engine/onUpdate()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2609]

Pls help

« Last Edit: August 05, 2016, 09:23:18 am by Tempus Vaito »

stefan

  • *
  • Posts: 2263
There are 3 common reasons this happens.
1. You are trying to refsr to an attribute with no value (an actir atribute with no actor assigned to it for example
2. A hidden listvthat hasnt been declared before you use it. Use set listAttribue to new list.
3. You are trying to get an item from a list where there is none. For example item #4 from list, while the list only has 3 items.

Tempus Vaito

  • Posts: 25
I've looked through all the events again and i can't find an attribute that isn't being called properly. I've even checked all the differences between the scene were everything works fine and the ones that don't. It has something to do with the enemy or the player actor because the error is returened as soon as they collide with eachother. So i don't understand how the collisions work on one scene and not the rest.

captaincomic

  • *
  • Posts: 6108
You can look at the source at <your workspace>/games-generates/<your game>/Source/scripts/ActorEvents_67.hx or post that file here, that might help finding the null attribute.

Tempus Vaito

  • Posts: 25
Alright, this is what was under ActorEvents_67.hx, i'm not exactly sure where the null attribute is because i've been working with the blocks.

class ActorEvents_67 extends ActorScript
{
public function new(dummy:Int, actor:Actor, dummy2:Engine)
 {
 super(actor);
}
override public function init()
{
      
      /* ======================== When Updating ========================= */
      addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
      {
         if(wrapper.enabled)
         {
            if((Engine.engine.getGameAttribute("collision") == true))
            {
               getActor(115).setAnimation("" + "Hurt");
               runLater(1000 * 1.5, function(timeTask:TimedTask):Void
               {
                  getActor(115).setAnimation("" + "Idle");
               }, actor);
            }
         }
      });
      
   }
   
   override public function forwardMessage(msg:String)
   {
      
   }
}

Tempus Vaito

  • Posts: 25
Ahh no worries, i previewed the code until i found the 67th event and there was a null pointer there, thank you for showing me how to deal with things like this