Android :: My First Game Is Getting Slow
Aug 11, 2009
I've followed the excellent article on game development here: http://www.rbgrn.net/content/54-getting-started-android-game-development, and started my game based on the Lunar Lander example. The Lander example re-draws the background and everything else on each "tick". I basically followed its example and I'm using my game's background image to essentially "clear" the canvas so that I can re-draw everything from a clean slate. This, as I've found, has a negative impact on performance as my game is beginning to slow down. My question is, what's the best way to optimize this? If I want to "clear" only certain parts of my canvas, how do I do that? I've read the documentation for android.graphics.Canvas, but am getting confused by a lot of jargon I don't understand such as "clip" and "matrix".
View 2 Replies
Jun 28, 2010
With 160,000 activations per day, it seems like a lot of us are using android devices, but there aren't many great or addictive games like there are on the iphone. Anyone have any reasons why?
View 16 Replies
View Related
Sep 16, 2009
I want to make a tile based game for android. At the moment I am drawing each tile as a separate bitmap. I have a big for loop that reads from a string and draws different tiles depending on what character it finds to draw the level. I have allowed the user to scroll the screen using scrolling gestures. However the game is too slow. It takes a long time to update the screen after the user scrolls. I presume this is because it has to draw each tile's bitmap individually. What would be a faster way to draw the level? I was thinking I could merge all the tiles into one bitmap. But I don't know how to do this.
Anyway here is my code so you can see the problem:
package org.example.tutorial2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
import org.example.tutorial2d.Panel;
public class Tutorial2D extends Activity implements OnGestureListener {
GestureDetector gestureScanner; Panel main;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureScanner = new GestureDetector(this);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
main = new Panel(this); setContentView(main); }
@Override public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
main.handleScroll(distanceX,distanceY); return true; }
@Override public boolean onDown(MotionEvent e) { return true;
} @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true;
} @Override public void onLongPress(MotionEvent e){
} @Override public void onShowPress(MotionEvent e) {
} @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }
And the class that does all the work:
package org.example.tutorial2d;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import org.example.tutorial2d.Point;
public class Panel extends View {
private int scrollX = 0; private int scrollY = 0;
public Panel(Context context) { super(context);
} @Override public void onDraw(Canvas canvas) {
/*Bitmap scratch; //Drawable scratch;
//scratch = getContext().getResources().getDrawable(
// R.drawable.icon); canvas.drawColor(Color.BLACK);
//scratch.draw(canvas); int origin = 0;
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5);
canvas.drawBitmap(scratch, origin, origin, null);
int width = scratch.getWidth(); int height = scratch.getHeight();
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3);
canvas.drawBitmap(scratch, origin + width, origin - 32, null);
[Code]
View 3 Replies
View Related
May 22, 2010
I have a square grid, for a turn based game ( grid is similar to the chess board ), but the moves in the games are different based on whether you have lapped your opponent pawn at least once or not.i.e if you have not lapped (beaten any of the opponents pawns) in the outer most grid as below.if you have lapped your opponent pawn once at least, then you get to reach home,this way.Any player having all his pawns reaching "home" first wins.The ones in yellow are safe-houses, i.e both the opponent pawn and the player's pawn get to stay in the same grid, this is not considered to be lapping ( the opponent ).The lapped pawn will return to its start point.Now the question is, what is the effective way to store the paths for the all the pawns.we will have 4 pawns for the player and 4 opponent pawns.Is there any pattern to store such static information, in a elegant way?
View 1 Replies
View Related
Nov 12, 2010
I have a puzzle game with a 7x7 grid of graphics, and a timer, its just about ready to go. But I am stuck on how to go about saving/continuing game. For example when someone exits I want them to be able to save and exit, then come back and click continue to pick up where they left off with all of the graphics in the right place, timer and score. I looked at onSaveInstanceState android examples, but not sure if this is what I need or how to implement it in my case.
View 8 Replies
View Related
Aug 26, 2010
I got my x on launch day no root no 2.2 all stock .well i've been noticing its getting slower don't have much installed only about 10 apps. The browser will start and then stop when u tell it to go somewere then after a dew sec it takes back off. Text message when u bring it up it takes about 10 sec to load then another lag to start typing and there wont be any old messages in box and when they do finally come up u can't scroll threw the old ones.
View 1 Replies
View Related
Oct 16, 2010
I got Samsung Galaxy 5.
I got some gameloft games (HD versions) installed but as I Run them only Top left (approx 1/4)view of game screen appers.
As whole game can not to fitted on one screen..
|--------------------|
| |
| |
| |
|Gamel |
| |
|--------------------
It looks like half of screen is cut like on "oft" of Gameloft is invisible
View 3 Replies
View Related
Jun 12, 2010
I am running Eclipse Galileo on an Intel Mac and after using it for a bit, it becomes very slow. By slow I mean switching between tabs and scrolling through source becomes nearly unusable. I have to close Eclipse and re-open it, and that usually only solves the problem for a short time.
View 11 Replies
View Related
Sep 20, 2010
I've got a Nexus One running a debug version of my application, and I just today downloaded and installed the 0.9.8 version of the SDK tools, and I swear that Debugging latency has increased incredibly. I never bothered to measure the overhead before the upgrade because I always found the phone's debugging overhead to be small enough to not affect matter. Well, now I have AI code which runs at ~10 MS standalone taking 300-400MS through debugging. A 40X performance loss is not something to cough at. Is it just me not seeing the performance loss previously, or has something broken?
View 2 Replies
View Related
Oct 22, 2009
I'm trying to perform a simple animation, but it seems quite choppy. This is it: Animation anim = new Translate Animation(0,0,-50,0); anim.set Duration(500); anim.setInterpolator(new LinearInterpolator()); myLinearLayout.set Animation(anim);the animation does what it's supposed to do, just very choppy - is there any reason why it's so slow? The linear layout I'm applying it to is pretty simple, just has a few children.
View 3 Replies
View Related
Oct 31, 2010
We use Opengl 2.0 to develop a video programmer on android with nexus one. We find that the fiction glTexImage2D is too slow,but we write a shader programmer accord to the sample GL2JNILib. I guess the GPU is not working, why it happened? how to fix it? Code...
View 4 Replies
View Related
Dec 29, 2009
I am trying to do AES decryption like this -Cipher cipher = Cipher.get Instance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, aesKey); cipher.update(encryBytes, 0, encrByteCount); and it is taking me about 2.5+ seconds to run just the cipher.update (i.e. I excluded the init and get Instance() calls) for 65KB of data -- which seems way too long.What this translates to (roughly) 60 seconds for a 1.5MB file. Which is uber slow.I *am* actually seeing 60 or so seconds when I try to decrypt that big of a file (looping through and feeding buffers).Does anybody know why AES decryption is so slow on Android? A co- worker is seeing times around 10 seconds for the same file on a RIM device.
View 2 Replies
View Related
May 27, 2010
I have a rooted mytouch 3G and I've been using the barnacle tether app for the last few months for internet on my laptop. Just recently I've been playing online poker on my laptop. It worked fine for about a day or so, then things started to get extremely slow, barely being able to load google (taking about a few minutes to load a basic html page). I don't know if it has something to do with using my phone for a connection with the poker clients or if it's just coincidence with the timing of it, I called T-Mobile and they said there are no problems at all with the coverage in my area and to do a Power cycle which didn't seem to help. Does anyone have ANY idea what could be wrong?
View 2 Replies
View Related
Nov 8, 2010
when draw YUV frame use opengl 2.0 and shader on nexus one,but the function glTexImage2D is too slow ,cost 40-60 ms who can fix it ? the key codes...
View 2 Replies
View Related
Feb 10, 2009
applications on my G1 device are very slow when GPS is ON. is there any solution for this. all the applications responds with force close messsage.
View 2 Replies
View Related
Aug 9, 2009
I am developing a small app that works as a speedometer with a build in histogram.
But it is quite unresponsive, I test it by driving in my car, and when i go from 80 to 0 it takes about 4-6 seconds before my needle is updated.
For simple outlier removal, i use a 1x3 median filter on my estimated speed the speed. Wich obviously will give me a delay one 1 sample.
******* Here's the real question :) ****** I thought i might get updates every second, and thus a delay of 2 seconds, wich wouldn't be to bad. but is GPS really that slow? or am i doing something completely wrong? *******
I have registrered a listener like so:
CODE:..............
To have a steady update of my speedometer, I use a timerTask to poll the listener for the last estimated result, and updates my speedometer view.
CODE:............
And the run method of my task:
CODE:.....................
View 7 Replies
View Related
Aug 21, 2009
I am currently using sensors and I would like to know if I can slow down the sampling rate. Indeed, I register my listener with the constant "SensorManager.SENSOR_DELAY_UI" (is it the slowest one of the four constants mentionned in the documentation?) but the rate is still quite high. I would like to be able to define the time before giving the new value (For example, I would like to wait two seconds before update).
View 4 Replies
View Related
Dec 5, 2009
I like to parse a XML file in android. It is taking too much time to parse a xml in android. what is the reason?.. It is taking more than 5 minutes also to parse a file. The same thing will continue in phone?...
View 2 Replies
View Related
Jul 16, 2009
I am starting a service from a broadcast receiver, using android:process=":remote", which from what I understand means unbind. That BR dies. The service is runs some TTS (text2speach) in a cycle until a second broadcast receiver comes into action and executes stopService.
I am using action names to start and stop the service.
The problem I am having is that after the stopService is executed the service is still alive for a good 20 seconds when finally dies from timeout. The other think I notice is that onDestroy() is never called.
View 2 Replies
View Related
Oct 28, 2010
I am trying to implement the Market License Checker, and am following the sample application. I am using the AESObfuscator class, but find that it takes a VERY long time (23 seconds on the emulator) to instantiate, which greatly delays the startup of my application. Is this normal, or am I doing something wrong? If it is normal, can I put the license check in a separate thread, or does it need to run in the main thread?
View 7 Replies
View Related
Oct 27, 2009
I'm using PDAnet on my HTC magic and speedtest on my computer is reading 1.7 mbps. I am also sharing the connection with my xbox360 to get on live. But Live is laggy. What am I doing wrong.
View 13 Replies
View Related
Feb 13, 2012
I want to code an app that reads sound from the mic and displays its freqs.
So I wrote a soundrader (thread) an a fft class and .. the fft class is to slow (I just tested it in the emu). Should i write the fft in c or what else can i do ?
View 2 Replies
View Related
Nov 24, 2009
I currently have a TabHost with 3 tabs.The content of each tab is an activity. The first and second tab make HTTP connections.The first tab still uses the UI thread (which i'm changing) so it would explain the slow orientation change since it's creating a fresh activity and making all those connections again. What I don't understand is why if I am on say Tab 3 which makes no connections at all does changing the orientation take such a long time (up to 5 seconds).In playing around with the TabWidget I noticed something that may be related.
View 2 Replies
View Related
Oct 12, 2009
I'm starting a ProgressDialog using:
ProgressDialog.show(Example.this, " " , " Loading. Please wait ... ", true,true);
Then running a block of code to download and parse XML.
The problem I'm having is that this is all running under a onClick button method, and that the xml is downloaded and parsed before the dialog is shown.
View 2 Replies
View Related
Sep 30, 2010
I am looking for an app for my Incredible that records video at a higher frame rate, then will play back at regular speed so that the video plays in slo-mo. My old LG Dare had this, and i used it quite often. ANyone know of any app out there that will do this? I have searched the forum, and the market, and cannot find what i am after.
View 3 Replies
View Related
Mar 11, 2009
Sometimes when I try to scroll using a scrollview (wrapped around a textview), there will be no response. I've noticed this in both my apps and the only common thing between them is the textview in both apps use Spanned (SpanableStringBuilder to be exact) text. This happens even when there is no activity on the window and no any pops up either.
View 7 Replies
View Related
Oct 12, 2010
I am having a customized list view in my application, which is showing an image and text.
The Image I am getting from URL, using the code below:
CODE:..............
All is working perfect, except the list view scrolling, its very slow. If I disable the images, the scroll speed smooth-ens , but with the image enabled, it lags alot.
Is there any possible way I can reduce or remove this lagging?
View 2 Replies
View Related
Oct 18, 2009
I found that if I keep pressing the touch screen, the app will slow down very much. Both happened in my code and the sample app.
The same issue happened to me on Windows Mobile, but not happened on Symbian. Anybody have some clew to fix it?
View 5 Replies
View Related
Dec 13, 2008
My G1 phone slows down after a while from switching it on, and if I switched off and re-switched it on it will get back to its normal state. So any clue why is that happening? I downloaded many apps from the market, is that the reason? and is there any application that shows the running applications in the background and their CPU and memory usage? And when I open the messaging and scroll through the messages it is way too slow.
View 5 Replies
View Related
Aug 16, 2010
I have seen that xml parsing is very slow. Using sax would be better, but benchmark show that sax work only 30% faster as dom. Is right? Is faster if I construct a "DOM" using sax?
To reduce time i like to cache xml file. Caching it as xml is not a good idea because the parsing time is there again the secondo time.
Should I use sqllite? Is faster? Is an idea to use an ObjectOutputStream? Can I put in asset a file maked by ObjectOutputStream or the serialized objects can be different in different mobile hardware?
View 5 Replies
View Related