Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi, i am wondering, can one use an already created graphic in a .obj file in java? For example, below is code that creates a ball, instead of doing this, i want to use the graphic as the ball, its a 3d football and i want to use it for a tilt football game im making at the moment. Im pretty new to android, very new to .obj and new enough to java so every bit of help is really appreciated.

Code:
Java
public class BallView extends View {

	public float mX;
    public float mY;
    private final int mR;
    private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    
    //construct new ball object
    public BallView(Context context, float x, float y, int r) {
        super(context);
        //color hex is [transparency][red][green][blue]
        mPaint.setColor(0xFF00FF00); //not transparent. color is green
        this.mX = x;
        this.mY = y;
        this.mR = r; //radius
    }
    	
    //called by invalidate()	
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawCircle(mX, mY, mR, mPaint);
    } 
}

So as mentioned above, i dont want a green dot/ball, i want my soccer ball graphic which is in a .obj file.

Thanks
Anto
Posted
Updated 20-Mar-13 4:31am
v2

1 solution

What you want to do is called a Bit Blit[^]. You need to have three images - the canvas, sprite and mask.
The general approach is to load up the sprite and mask into memory and then apply them to the canvas image whenever the sprite moves.
Java provides the ImageIcon[^] class that takes a lot of the pain out of it for you; usage here[^]. However if this woprks in Android, I do not know.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900