If I comment out the line decoding the bitmap and (xpos and ypos since they use it) It doesn’t crash. However if they are uncommented it crashes. I don’t know why.
public class ClSprite implements Parcelable{
private Bitmap SpriteBitmap; // the actual bitmap
private boolean Touched; // if droid is touched/picked up
private int XVelocity;
private int YVelocity;
private int XPosition;
private int YPosition;
private boolean Visible;
private String SpriteType;
private int BitmapLocation;
public ClSprite(int givenBitmapLocation, int xPosition, int yPosition, int VelocityX, int VelocityY, String spriteType)
{
//Needs this constructor filled in.
BitmapLocation = givenBitmapLocation;
SpriteBitmap = BitmapFactory.decodeResource(Game.context.getResources(),R.drawable.icon);
XPosition = xPosition - SpriteBitmap.getWidth()/2;
YPosition = yPosition - SpriteBitmap.getHeight()/2;
XVelocity = VelocityX;
YVelocity = VelocityY;
Visible = true;
SpriteType = spriteType;
}
I bet your LogCat shows an OutOfMemoryError. Something like this: “OutOfMemoryError: bitmap size exceeds VM budget”.
If this is true you need to fix or dynamically scale your bitmap. Please have a look here:
http://code.google.com/p/android/issues/detail?id=8488