Why mImage is not displayed?
public class Manager extends Thread{
private SurfaceHolder mSurfaceHolder;
private boolean mRunning;
public Drawable mImage;
public Manager(SurfaceHolder surfaceHolder, Context context){
mSurfaceHolder = surfaceHolder;
mRunning = false;
Resources res = context.getResources();
mImage = res.getDrawable(R.drawable.nhero2);
public void setRunning(boolean running)
{
mRunning = running;
}
public void run()
{
while (mRunning)
{
Canvas canvas = null;
try
{
// подготовка Canvas-а
canvas = mSurfaceHolder.lockCanvas();
synchronized (mSurfaceHolder)
{
// собственно рисование
//doDraw(canvas);
mImage.draw(canvas);
}
}
catch (Exception e) { }
finally
{
if (canvas != null)
{
mSurfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
}
}
P.S. sorry 4 my english
P.P.S.
i trying to create my own scrool shooter hah
full code here(sry for bad comments)
class Manager http://pastebin.com/Sjd57uqT
class View and class scrolBckgr http://pastebin.com/A5u5UJea
You need to call mImage.setBounds(…); otherwise the canvas doesn’t know where to draw the Drawable.