android - Creating an array of button sprites with andengine NullpointerException -


i've been racking brain trying figure out day. had enough trouble getting database work (which now). problem i'm having null pointer exception. here important part of file (its way big post whole thing.

        db = new mydatabase(activity);      attackcursor = db.getplayerattackweapons();     attackbuttons = new buttonsprite[attackcursor.getcolumncount()];     if (attackcursor != null) {         attackcursor.movetofirst();       while (attackcursor.isafterlast() == false) {                  attackbuttons[attackbuttonscounter] =                   new buttonsprite(0, 0, playermenu.getplayermenuattacktr(),                 engine.getvertexbufferobjectmanager()) {             @override             public boolean onareatouched(touchevent pscenetouchevent,                     float ptoucharealocalx, float ptoucharealocaly) {                  if (pscenetouchevent.isactiondown()) {                     beep.play();                     attacktype = attackcursor.getint(0);                     this.setvisible(false);                     selecttargetmessage.setvisible(true);                     gamescene.unregistertoucharea(this);                     playermenu.setvisible(false);                     this.setparent(playermenuattack);                  }                  return super.onareatouched(pscenetouchevent, ptoucharealocalx,                         ptoucharealocaly);              }         };         attackbuttons[attackbuttonscounter].setcolor(color.yellow);         attackbuttons[attackbuttonscounter].setposition(0,attackbuttonsypos - 0-attackbuttons[attackbuttonscounter].getheight());          attackbuttonsypos = attackbuttonsypos - 90;          attackbuttonscounter++;         attackcursor.movetonext();       }      } 

now, there isn't errors coming part of code, should yield visible buttons on screen. not. furthermore nullpointerexception coming in portion of code:

playermenuattack = new sprite(0, 0, playermenu.getplayermenuattacktr(),             engine.getvertexbufferobjectmanager()) {         @override         public boolean onareatouched(touchevent pscenetouchevent,                 float ptoucharealocalx, float ptoucharealocaly) {              if (pscenetouchevent.isactiondown()) {                 beep.play();                 int = 0;                 while (i <= attackbuttons.length)                  {                     //getbuttontogglers(attackbuttons[i]);                     attackbuttons[i].setvisible(true);                     i++;                 }              }              return super.onareatouched(pscenetouchevent, ptoucharealocalx,                     ptoucharealocaly);          }     };     playermenuattack.setposition(0,0); 

i'm getting nullpointer exception when click on playermenuattack sprite. pointing line containing attackbuttons[i].setvisible(true); i'm @ total loss....


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -