- Home /
What is wrong with my EX2D code?
Hello all,
I'm new to programming and I'm attempting to create a game as a project to help me learn the ropes. I've purchased EX2D to help with my sprite animations. I'm getting the following error trying to animate a sprite:
NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
Char Move with Anim1.Update () (at Assets/Char Move with Anim1.js:23)
The following is my code:
var xmovement : float = 0;
var ymovement : float = 0;
public function Start()
{
var spanim:exSpriteAnimation;
var sprite:exSprite;
sprite.spAnim = GetComponent.<exSpriteAnimation>();
sprite.spAnim.Play("PlayerIdleAnimation");
}
public function Update()
{
var spanim:exSpriteAnimation;
var sprite:exSprite;
sprite.spAnim.Play("PlayerIdleAnimation");
/*while(xmovement > 0)
{
sprite.spanim.Play("PlayerWalkUpAnimation");
}
while(xmovement < 0)
{
sprite.spanim.Play("PlayerWalkDownAnimation");
}
while(ymovement > 0)
{
sprite.spanim.Play("PlayerWalkLeftAnimation");
}
while(ymovement < 0)
{
sprite.spanim.Play("PlayerWalkRightAnimation");
}*/
}
The part towards the bottom is commented out because I'm trying to get the first part working properly before I implement the rest.
Any pointers or corrections / criticisms are much appreciated.
Thanks in advance!
Answer by Wu Jie · Aug 02, 2012 at 01:35 AM
Hi,
It seems you are assign a null-reference object to spAnim, but ex2D already provide sprite.spanim
Your answer
Follow this Question
Related Questions
i am having a problem in using ex2d animation sprite.. 0 Answers
Idle animation not working 0 Answers
i am having a problem in using ex2d animation sprite.. 0 Answers
change sprite animation in ex2d ? 4 Answers