2010-12-21 119 views
1

所以我使用處理IDE,並不斷得到這個奇怪的空指針異常。處理和空指針異常彈出

異常在線程 「主」 顯示java.lang.NullPointerException
在processing.core.PApplet.displayable(PApplet.java:9944)
在processing.core.PApplet.main(PApplet.java:7425 )

這就是我得到的所有信息,所以我甚至無法追蹤到它發生的位置。這裏是我的代碼

import TUIO.*; 

TuioProcessing tuioClient; 
Vector tuioCursorList; 
Point cols[][]; 


void setup(){ 
    size(1440,900); 
    tuioClient = new TuioProcessing(this); 
    tuioCursorList = tuioClient.getTuioCursors(); 
    init(); 
} 

void draw(){ 
    background(0); 


} 

void init(){ 
    cols = new Point[width][height]; 
    for(int i = 0; i<width;i++){ 
    for(int x = 0; x<height;x++){ 
     cols[i][x] = new Point(i,x); 
    } 
    } 
} 

class Point{ 

    int x, y; 
    boolean alive; 
    int life; 
    int pointColor; 

    Point(int _x, int _y){ 
    x = _x; 
    y = _y; 
    pointColor = 0; 
    alive = false; 
    fill(pointColor); 
    point(x, y); 

    } 

    void checkStatus(){ 
    if(alive = true){ 
     isAlive(); 
    } 
    else{ 
     isDead(); 
    } 
    } 

    void isDead(){ 
    pointColor = 0; 
    life = 0; 
    } 

    void isAlive(){ 
    pointColor = 255; 
    life = 100; 
    } 

    void kill(){ 
    life--; 
    } 

} 

// called when an object is added to the scene 
void addTuioObject(TuioObject tobj) { 
    println("add object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+"  "+tobj.getY()+" "+tobj.getAngle()); 
} 

// called when an object is removed from the scene 
void removeTuioObject(TuioObject tobj) { 
    println("remove object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")"); 
} 

// called when an object is moved 
void updateTuioObject (TuioObject tobj) { 
    println("update object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")  "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle() 
    +" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+"  "+tobj.getRotationAccel()); 
} 


// called when a cursor is added to the scene 
void addTuioCursor(TuioCursor tcur) { 
    println(tcur.getX()+", "+tcur.getY()); 
} 

// called when a cursor is moved 
void updateTuioCursor (TuioCursor tcur) { 
    println(tcur.getSessionID() + " - " + tcur.getX()+", "+tcur.getY()); 
} 

// called when a cursor is removed from the scene 
void removeTuioCursor(TuioCursor tcur) { 
} 

// called after each message bundle 
// representing the end of an image frame 
void refresh(TuioTime bundleTime) { 
    redraw(); 
} 

任何人都可以幫助我找出這個奇怪的錯誤。任何幫助將不勝感激

+4

這甚至不是可編譯的。 – Falmarri 2010-12-21 20:28:28

+0

這個奇怪的錯誤有文檔,它清楚地表明出了什麼問題。此外 - 一個擁有「9000多個」行的小程序?這聽起來不太好。 – Bozho 2010-12-21 20:44:23

回答

3

重命名您的init()函數爲別的東西。您正在重寫Processing的內置類的init()函數。