• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Drawing part of a bitmap

I'm making a game called Pakku Pakku Man, which is a Pac-Man clone. For the characters, I'm using a class called AnimatedSprite, and the language is Java. The class file imports
android.content.Context;
android.graphics.Bitmap;
android.graphics.BitmapFactory;
android.graphics.Canvas;
android.graphics.Rect;

What I want to do is make Pakku Pakku Man go through a tunnel on one end of the maze and emerge out the other. Currently, when he tries to go through a tunnel, the program crashes- apparently due to the program trying to draw pixels off screen. I figure what I need to do is have the program not draw any part of Pakku Pakku Man that's off screen. Thus, as he goes through the tunnel, less and less of him is drawn until no part of him is drawn at all until he emerges through the other tunnel of course.
 
I'm making a game called Pakku Pakku Man, which is a Pac-Man clone. For the characters, I'm using a class called AnimatedSprite, and the language is Java. The class file imports
android.content.Context;
android.graphics.Bitmap;
android.graphics.BitmapFactory;
android.graphics.Canvas;
android.graphics.Rect;

What I want to do is make Pakku Pakku Man go through a tunnel on one end of the maze and emerge out the other. Currently, when he tries to go through a tunnel, the program crashes- apparently due to the program trying to draw pixels off screen. I figure what I need to do is have the program not draw any part of Pakku Pakku Man that's off screen. Thus, as he goes through the tunnel, less and less of him is drawn until no part of him is drawn at all until he emerges through the other tunnel of course.

This would be much easier done with OpenGL. OpenGL isn't just for 3d Rendering. It also has very powerful methods for animations and 2D drawing. Much more powerful than Canvas can ever do.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones