I am new in android plateform. I am working with graphics.
I can move an image in the emulator screen. I set my image as background with the java coding. the coding set is as follows::
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;
public class BounceView extends View {
protected Drawable myBackground, mySprite,mySprite2;
protected Point myBackgroundPos=new Point(0,0);
protected Point mySpritePos = new Point(10,100);
protected Point mySpritePos2 = new Point(15,800);
protected enum HorizontalDirection {LEFT, RIGHT}
protected enum VerticalDirection {UP, DOWN}
protected HorizontalDirection myXDirection = HorizontalDirection.RIGHT;
protected VerticalDirection myYDirection = VerticalDirection.UP;
public BounceView(Context context){
super(context);
// this.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.test));
this.myBackground=this.getResources().getDrawable(R.drawable.test);
this.mySprite = this.getResources().getDrawable(R.drawable.splash1);
this.mySprite2 = this.getResources().getDrawable(R.drawable.splash1);
}
protected void onDraw(Canvas canvas) {
this.myBackground.setBounds(this.myBackgroundPos.x,this.myBackgroundPos.y,
this.myBackgroundPos.x + 480, this.myBackgroundPos.y + 800);
this.mySprite.setBounds(this.mySpritePos.x, this.mySpritePos.y,
this.mySpritePos.x + 100, this.mySpritePos.y + 100);
// Toast.makeText(getContext(),"button pressed"+this.mySprite.x,Toast.LENGTH_SHORT).show();
this.mySprite2.setBounds(this.mySpritePos2.x, this.mySpritePos2.y,
this.mySpritePos2.x + 100, this.mySpritePos2.y + 100);
if(myBackgroundPos.y ==this.getBottom()){
this.myYDirection = VerticalDirection.DOWN;
this.myBackgroundPos.y-=10;
}
if (mySpritePos.x >=this.getWidth() - mySprite.getBounds().width()){
this.myXDirection = HorizontalDirection.LEFT;
//Toast.makeText(getContext(),"button pressed"+this.mySpritePos.x,Toast.LENGTH_SHORT).show();
} else if (mySpritePos.x <= 0) {
this.myXDirection = HorizontalDirection.RIGHT;
}
if (mySpritePos2.y >= this.getWidth() - mySprite2.getBounds().width()){
this.myYDirection = VerticalDirection.UP;
} else if (mySpritePos2.y <= 0) {
this.myYDirection = VerticalDirection.DOWN;
}
if (this.myXDirection == HorizontalDirection.RIGHT) {
this.mySpritePos.x+= 10;
} else {
this.mySpritePos.x -= 10;
}
if (this.myYDirection == VerticalDirection.UP) {
this.mySpritePos2.y -= 10;
} else {
this.mySpritePos2.y += 10;
}
this.myBackground.draw(canvas);
this.mySprite.draw(canvas);
this.mySprite2.draw(canvas);
}
Now I want to animate the background image along with with other images.. I am sticking with that..
I know this the right place to get the solution..
Please help me.. Its urgent for me
Thanks in advance


