j2me sprite array
Posted
by
danis
on Game Development
See other posts from Game Development
or by danis
Published on 2012-08-27T16:50:39Z
Indexed on
2012/08/27
21:57 UTC
Read the original article
Hit count: 128
sprites
I`ve tried to put the same Image into an array (array contains 22 Images) to form inventory.
for(int i=0;i>22;i++){
invSprite[i] = new Sprite(ingame);
invSprite[i].defineReferencePixel(0,0);
}
and
if(inventory){
for(int i=0;i>22;i++){
if(i>=11){
invSprite[i].setRefPixelPosition(0+15*i, 27);
}else{
invSprite[i].setRefPixelPosition(0+15*i, 42);
}
invSprite[i].paint(g);
}
}
If the inventory is on it will show those Images but it`s not.
PS if I would try
invSprite[0].setRefPixelPosition(10, 27);
invSprite[0].paint(g);
it would throw an java/lang/NullPointerException
© Game Development or respective owner