BringBackJiraiyaSensei
Newbie
How do i get a certain resource based on a name given in the string _bitmap?
it works when i do like this, but i would much rather that i could set the name of the resource in the constructor so i can reuse the class for other animations.
Code:
public AnimatedObject(Context _context, Point _pos, int _rows, int _columns, String _bitmap)
{
setUsesAnimation(true);
pos = _pos;
rowsInSheet = _rows;
columnsInSheet = _columns;
String bitmapstring = _bitmap;
bitmap = BitmapFactory.decodeResource(_context.getResources(), R.drawable.bitmapstring);
bitmapHeight = bitmap.getHeight() / rowsInSheet;
bitmapWidth = bitmap.getWidth() / columnsInSheet;
}
it works when i do like this, but i would much rather that i could set the name of the resource in the constructor so i can reuse the class for other animations.
Code:
public AnimatedObject(Context _context, Point _pos, int _rows, int _columns)
{
setUsesAnimation(true);
pos = _pos;
rowsInSheet = _rows;
columnsInSheet = _columns;
bitmap = BitmapFactory.decodeResource(_context.getResources(), R.drawable.fire);
bitmapHeight = bitmap.getHeight() / rowsInSheet;
bitmapWidth = bitmap.getWidth() / columnsInSheet;
}
Last edited by a moderator:
