Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  My logic is baffled  (Read 476 times)
0 Members and 2 Guests are viewing this topic.
Offline minosu

JGO n00b
*

Posts: 5



« on: 2012-01-13 17:58:13 »

just out of curiousity howcome i get a nullpointerexception...

1  
2  
3  
4  
5  
6  
7  
Animation animation;
     
animation = new Animation(true);//runR
animation.addFrame(2, 140);
animation.addFrame(4, 140);
System.out.println(animation);
animations.addAnimation(animation);


... at the last line?

Offline aazimon

Full Member
**

Posts: 208
Medals: 5



« Reply #1 on: 2012-01-13 18:03:10 »

Where do you create animations variable?
Offline minosu

JGO n00b
*

Posts: 5



« Reply #2 on: 2012-01-13 18:07:56 »

create it here? then bring it into the AnimationManager which copies it into its array of Animations.

what do you mean by 'where'?
Games published by our own members! Go get 'em!
Offline ra4king

JGO Kernel
*****

Posts: 3158
Medals: 196


I'm the King!


« Reply #3 on: 2012-01-13 18:09:36 »

The only possible way a NPE could be thrown at that line is that the variable "animations" is null. What aazimon was asking: where do you assign the "animations" variable?

Offline minosu

JGO n00b
*

Posts: 5



« Reply #4 on: 2012-01-13 18:13:01 »

I thought
1  
animation = new Animation(true);//runR

is 'assigning' the 'variable'?
Offline ra4king

JGO Kernel
*****

Posts: 3158
Medals: 196


I'm the King!


« Reply #5 on: 2012-01-13 18:14:22 »

animations

This is why it is not a good idea to have two variables so closely spelled Wink

Offline minosu

JGO n00b
*

Posts: 5



« Reply #6 on: 2012-01-13 18:15:32 »

O_O
loool i'm blind ><
Offline ra4king

JGO Kernel
*****

Posts: 3158
Medals: 196


I'm the King!


« Reply #7 on: 2012-01-13 18:18:03 »

Hehehe....so was "animations" null?

Offline minosu

JGO n00b
*

Posts: 5



« Reply #8 on: 2012-01-13 18:21:48 »

yes >>

i just plain forgot... that it needed to be initiated.
Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #9 on: 2012-01-13 18:23:24 »

yeah call it animationList or allAnimations or something =P

Games published by our own members! Go get 'em!
Offline ra4king

JGO Kernel
*****

Posts: 3158
Medals: 196


I'm the King!


« Reply #10 on: 2012-01-13 18:28:11 »

Teehee Smiley

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.088 seconds with 19 queries.