Android :: Drawing Bitmaps On Screen In Game Without Slow Performance

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]

Android :: Drawing Bitmaps on Screen in Game Without Slow Performance


Android :: App Gets Too Slow While Drawing Two Bitmaps On A Canvas / Fix It?

Nov 4, 2010

I have two bitmap overlapped .The top bitmap is transparent and when user touch to screen i copy pixels from another bitmap to top bitmap.My goal is to give to users the feeling of erasing image with touching to see another image.However it is not working properly especially when user drags his finger too fast on the screen.I made a few tests and i beleive drawing bitmaps to the canvas every time cause the lag but i don't know how to fix it.

View 1 Replies View Related

Android :: Game Stutters When Drawing Outside Screen

Apr 25, 2010

I have a game built for 480x320 screen resolution. When playing the game on a phone with a higher screen resolution (480 x 800 or 480 x 856) the game automatically stretches to fit the screen which works great. Because of different screen dimensions there is a piece of the screen on the right side (game is in landscape mode) that is black, not used by the game. I want to fill this up with an image, so the whole screen is filled. I only draw that image on screens bigger than 480x320. This all works fine, the image is displayed exactly the way I want to. The only problem is that the game runs less smooth then it used to run. There are small stutters noticeable. When I just draw a rectangle instead of an image the same problem occurs. Does anyone have an idea why this is happening?

View 8 Replies View Related

Android :: FrameLayout For Drawing Overlays In Game?

Nov 15, 2010

I've got a game, a custom View class draws my gameboard. I'm thinking of drawing some elements on a separate layer above the gameboard. I could do this in the View's canvas code, but since they won't change frequently, was thinking of introducing a frame layout to display this top layer.I'm not sure which route to take, the only reason I wouldn't do the FrameLayout is because I'm not sure if it has an impact on battery life. Everytime onDraw() is called, the system probably has to do an alpha composition of the two layers. Is that more battery consuming than drawing the elements from that layer myself in my canvas on every frame? Hard to answer since I'm not sure how complex the drawing will be yet, any general opinions?

View 1 Replies View Related

Android :: Compensate Drawing Delay From Game Logic Updates

Aug 24, 2010

Now I have (1: the UI-loop, there my SurfaceView is placed), (2: a second thread, there the draw function from the UI-loop is called AND the update calculations from my Engine) and (3: the engine, there all the calculations stuff are).Now I wonder how the best and smoothest way to do the SurfaceView independent from the actual frame rate. How shall I do so it will compensate if there is a low frame rate?

View 2 Replies View Related

Games :: Drawing Or Pictionary Style Game

Oct 17, 2010

Is there a game for android in which a person draws stuff on screen and others users guess? I have a game like it on my sister's ipad but want one for my Samsung Epic. Game is super addicting! Please let me know!

View 4 Replies View Related

Android :: Eclipse IDE With ADT Plugin - Performance Too Slow

Feb 22, 2010

I just installed the latest version of Eclipse IDE for Java Developers together with the ADT plugin on my Mac (2.8 GHz, 4 GB Ram).

- Opening new files from the package explorer.
For example, opening a layout xml file takes 1-2sec- And the mouse pointer changes.
- Switching between tabs
- Resizing views in the workspace

The performance rapidly decreases when I open more files. Are all of you developing under these circumstances? How can I speed up eclipse?

View 4 Replies View Related

Android :: Extracting Zip To SD Card Very Slow - Optimize Performance?

Oct 20, 2010

my app downloads a zip with about 350 files. A mix of JPG and HTML files. The function i wrote to do it works just fine but the unzipping takes for ever. At first i thought the reason might be that writing to the sd-card is slow. but when i unzip the same zip with an other app on my phone it works much faster. is there anything that i could do to optimize it?

here is the code:.................

View 1 Replies View Related

Android :: AutoCompleteTextView Static Data / Slow Performance

Jun 1, 2010

I am facing the following problem: I have a big list of street names(~2000 entries), which is stored as a variable. I have an AutoCompleteTextView which should complete the names. The process takes really long time(approx. 2 - 3 seconds) to complete the suggestion. Is there any way to speed this up? I am pasting my code, if this is necessary:The getStreetsData() method simply returns the static list of the names.

View 2 Replies View Related

Android :: Emulator Performance - Apps Running Slow?

Sep 29, 2010

A while back I mentioned that running the imported p2p codebase I have on the emulator (on a fairly powerful laptop with plenty of mem and a fast processor) was pretty slow. I blamed all that on the codebase and in fact I was able to profile it and make it much lighter. Well still the overall app performance is slow --- and I am finding that most apps I run on the emulator are fairly slow. Is this a common trend? I do expect emulators, who are by no means a real device, to have such processing delays but are they in general this slow? Any metrics or any other feedback from anyone that depict the factor of slowdowns you would expect on an emulator vs the real device? I know a lot of this are machine dependent as well but consider an idle powerful machine. And regarding memory - I am loading Eclipse with close to 1G to be able to run the emulator and its basic services - is that normal?

View 3 Replies View Related

Android :: Game Performance Degrading Over Time

Nov 14, 2010

I've written a game and I've noticed that after playing for about 20-30 minutes the performance starts degrading. By performance degradation I mean my average frames-per-second seem to slowly drop. I'm doing all my allocs at the beginning and the only things that alloc in game according to DDMS are Integer.toString operations (for integer values I need to draw with drawtext) and setBounds on some drawables.

I'm calling System.gc() periodically, when I know not much is going on in-game (e.g. between waves of enemies). I'm doing this in order to avoid GC from happening during critical gameplay periods. If you know the answer to any of the following, please do tell (even a guess would do) Why is performance degrading with time? What could be causing this? Is there a way to avoid allocs due to Integer.toString and Drawable.setBounds calls?

View 16 Replies View Related

Nexus :: Slow Network Performance From Three

Mar 18, 2010

Just got my N1 upgraded to unlimited web use through 3. Had to set up the APN. Did that in work and looked forward to `consuming` on the train journey home.

How cheesed off was I when I got diddly squat in the way of speed and function from the network?!

Endomondo - did not work, no maps
Google maps - never registered my position
Web - realllly slow to load anything
GPS tester - only found one or 2 satellites nd never made proper contact
Anyone else got an N1 with Three? Performace pants? Any other networks just as bad?

View 10 Replies View Related

Sprint HTC Hero :: Installed Last.fm - Slow Performance / Won't Boot

Oct 26, 2010

I'm rooted running CM6, have been for awhile. I was just recently installing last.fm and I guess I pressed something that caused my phone to slow way down, pretty much froze up, so I rebooted it. It booted all the way up and then rebooted itself again and now it won't go passed the white htc screen.

View 2 Replies View Related

HTC Desire HD :: 3D Game Performance - Better Graphic Processor

Nov 9, 2010

Lot of people are saying that the Samsung Galaxy S has a better graphics processor than the DHD so it's better for gaming. I was wondering if anyone has tried any of the Gameloft HD games on the DHD yet, or the Playstation emulator?

View 19 Replies View Related

Sony Ericsson Xperia X10 :: Phone Performance Is Very Slow After Update

Nov 29, 2010

i've found that my x10 really disappointed me even after updated.. still alot of bugs! and so slow~==... that really irritates me alot... SE pls do something to improve the phone as i can see the specification of this phone is really good just that the software sucks. and this phone is not cheap at all. cost me almost like the price of an iphone

View 3 Replies View Related

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 View Related

Jelly Bean :: Samsung Galaxy Grand Slow Performance After 4.2.2 Upgrade

Sep 16, 2013

I have upgraded my Galaxy Grand Duos I-9082 from Jelly bean 4.1.2 to 4.2.2 and the phone hangs randomly. on 4.1.2 it was working truly commendable.

View 24 Replies View Related

Games :: Game Dev's Have Been Slow To Develop For Android?

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

Android :: Eclipse Android SDK Slow Performance

Oct 17, 2010

I am running eclipse on my windows 7 machine, 6bit with 6gb ram and core 2 duo. I am currently running Eclipse 3.6 and android 2.2 SDK. I am running jdk 1.6. I am noticing that when coding and the context popups to list methods of a class, it hangs Eclipse for up to 15 seconds. This is very frustrating. One thing to note, when Eclipse hangs, my processor is maxed out, and is being worked by a java process. So its doing something whatever it is. But frequently everytime I finish an object with a period and the context box pops up, its becoming too painful to work with.

I changed some settings in the Eclipse.ini file such as:
-Xms1024m
-Xmx1024m
--launcher.XXMaxPermSize 512m

View 2 Replies View Related

HTC Desire : When Drawing Unlock Screen - Big Lag Till Home Screen Comes Up

Nov 5, 2010

Ii haven't made any big changes to my Desire and all was working well. suddenly a couple of days ago i noticed that things slowed down significantly.
exmples: when drawing the unlock screen, there is a big lag till the home screen comes up huge lag in opening programmes or menus

so, the only app i recently installed was the BA (british airways) android app. could this have affected the whole phone?

what steps can i take to check what might be wrong?looking at the SPARE PARTS app, i can see that CPU usage shows a huge bar for "init".i don't know if this is a normal process? anyone got info on this? might have nothing to do with my phone lagging of course.

View 1 Replies View Related

Android :: Drawing On WVGA Screen?

Jan 7, 2010

I wrote a reading software. I implemented the page turning effect when user tap the screen to turn to next/pre page. The display is ok on G1 (320X200 size) but it can not works well on Droid(480*854 size), the font looks a litter fuzzy, not clear as G1. I explain my codes for page turning:

1) create a canvas A

2) create bitmap.

3) set bitmap on canvas A

4) draw the new page content on canvas A

5) the current showing page has been saved in bitmap before since we do from step 1) to setp 4),

6) In order to implement the turning effect of scrolling from left to right, I draw the old bitmap part and draw the new bitmap part until the whole new bitmap has been drawn. all of bitmaps are drawing by canvas.drawBitmap() in onDraw() function.

7) when step 6) is done, it means the new page has been shown on screen, and the bitmap has been saved to use in next page turning.

The above is the whole actions for my page turning. On G1, no problem. But on Droid phone, the font is not clear, I tried if I directly draw text by canvas in OnDraw() not through bitmap, It is ok, but it can not implement the page turning effect that I need. I don't know why, could you please help me to take a look and tell me where is wrong or miss some steps?

View 2 Replies View Related

Android :: Drawing GL Object Proportional To Screen?

Nov 15, 2010

How to draw, say, a rectangle on the screen with it being proportional to the current device?
e.g. a rectangle, centered on the viewport, one pixel smaller than the screen on each border.

I can live with Orthogonal, but would like perspective (basically everything at Z=something should be proportional to the screen, and the upper parts of the elements being distorted by perspective)

I can calculate everything on my own if i know the relation... but i don't have a starting point.

I could experiment and get to a relation myself... i even resorted to that while coding for the Wii, but that's a really bad decision on Android and all the screen ratios/sizes out there...

View 1 Replies View Related

Android :: Drawing Image In Full Screen On Different Device

Sep 3, 2009

My application required to draw image on full screen. now the phone screen size will be different. So will i have to make different image for each phone or i can use just one image and it can display on full screen in any device.

View 2 Replies View Related

Android :: Drawing 2D Stuff On Screen In OpenGL Over 3D Scene

Jun 27, 2010

Can somebody take me step-by-step how to draw 2D stuff over a 3D scene (such as controls, etc.). What I've been doing so far has not been working (it only draws the 3D scene), which is (in every frame): draw the 3D scene as normal, projection matrix mode, load identity, call GLU.gluOrtho2D(gl, 0, myScreenWidthInPixels, 0, myScreenHeightInPixels), switch the array pointers (vertices and texture coords) to the ones for my 2D stuff, then drawElements with an appropriate index list. (then switch the array pointers back so the 3D stuff works again).I get nothing added to the screen (just the 3D stuff).Do I need to be doing something else for it to draw? Can somebody take me step-by-step?

View 5 Replies View Related

Android :: Drawing A Camera Preview In A Certain Area Of Screen

Nov 16, 2009

I have been playing with Android for a couple of months, so I'm still kindof newbie on this. I've looking for previous questions like mine, but I was unable to find any proper solution. So here goes my question:

I'm trying to draw a Camera Preview in a certain part of the screen (for instance, square upper-left). So what I suppose I should do is the following:

CODE:.............

And on the Preview Class I have the following lines:

CODE:....................

View 2 Replies View Related

Android :: Off Screen Drawing In Droid Like A ImageContext In Objective C?

Sep 17, 2010

Is there off screen drawing possible in android like a imageContext in objective C. if it is kindly tell me the link or some kind of hint.

View 2 Replies View Related

Android :: Changing Drawing With OpenGl When User Touches Screen

Nov 10, 2010

I'm developing an Android application. I'm very new on it. I have the following classes:
class CustomGLSurfaceView extends GLSurfaceView
class CustomRenderer implements GLSurfaceView.Renderer
CustomGLSurfaceView uses CustomRenderer to render a cube on onDrawFrame method.

I've added an onTouchEvent(MotionEvent event) on CustomGLSurfaceView to manage touch events:
class CustomGLSurfaceView extends GLSurfaceView {
// For touch inputs - previous touch (x, y)
private float previousX; private float previousY;
private CustomRenderer myRenderer; public CustomGLSurfaceView(Context context) {
super(context); myRenderer = new CustomRenderer(); setRenderer(myRenderer);
} @Override public boolean onTouchEvent(MotionEvent event) {
float currentX = event.getX(); float currentY = event.getY();
switch (event.getAction()) { case MotionEvent.ACTION_MOVE:
myRenderer.handleMovement(currentY, currentY, previousX, previousY);
} // Save current x, y
previousX = currentX; previousY = currentY;
return true; // Event handled } }

May I have to modify onDrawFrame to draw something new or to rotate the cube? I thing I must do it on handleMovement.

View 1 Replies View Related

Android :: How Does Emulator Performance Compare To Real Device Performance?

May 23, 2010

I'm looking into writing an Android game, tough I don't curerntly own an Android device. For those of you who own a device, how does the performance on the emulator relate to real device performance? I'm especially interested in graphics related tasks.This obviously depends on both the machine running the emulator, and the specific device in question, but I'm talking rough numbers here.This question is a duplicate, but since that post is heavily outdated, I figured it's irrelevant by now.

View 3 Replies View Related

Android : Does Screen Orientation Change / Effect Performance?

Jan 21, 2009

From reading Romain Guy's blog post, I understand keep static reference to a Drawable can create huge memory leaks. So what is the recommended solution if I don't want to reload my big Drawable image every time screen orientation changes and effect on performance? Currently my app takes >3 seconds to complete each orientation change.

View 8 Replies View Related

Motorola CLIQ : Moto Update New - Improved Performance - Battery Life - Software Performance And Stability

Feb 20, 2010

Motorola CLIQ Over-the-Air Update
[Retail Partner Sales - T-Mobile Employees and Authorized Dealers]

February 19 Update
The over-the-air update for the Motorola CLIQ has been delayed to the week of February 22. An updated article will be available once a date has been determined.

On February 18, Motorola will begin sending over-the-air (OTA) software updates to Motorola CLIQ customers. The software update will improve device performance and resolve several known issues.
Improved Performance:
Improved battery life
Improved software performance and stability
Improved widget response
Decreased Force Close error messages
New Manage SIM Card application
Support of .WMA and .WAV media files
Removal of the imeem mobile application
Known Issues Resolved:
Accessories & Bluetooth
Error: 'Unable to pair' or 'Unable to connect to device'
Call functions
Can activate other functions while listening to visual voicemail
Call not ended by pressing the End key
Speakerphone turns on unexpectedly when answer incoming call
Plays ringtone or vibrates while on an active call
Unable to answer incoming call using �Slide to answer� feature
Accidentally opens Dialer or makes outbound while holding device
Device hardware (battery, keys, power, screen)
Battery indicator may not display accurate battery power
Call not eded by pressing the End key
Touch screen issues
Cannot answer incoming call using the Slide to answer feature
Incorrect keys registered using on-screen keyboard
Touch display appears to have �dead spots� that are unresponsive
Accidentally selects item when trying to flick through screens or menus
Messaging
Wrong message deleted
Phone may reset when turning Wi-Fi off in area with no Wi-Fi coverage
Customers can manually download the OTA on demand by going to Settings > About Phone > System Updates. Customers do not need to wait for a notification message to download.
Action Steps
Be aware of the fixes and enhancements included in the Motorola CLIQ update.
If customers are experiencing any Known Issue that will be resolved by the software update:
Do not file a handset exchange
Advise customers that the issue will be resolved by a software update on February 18.
Important Rebate Changes
[Retail Partner Sales - T-Mobile Employees and Authorized Dealers]
Customers eligible for rebates as part of new activations or upgrades must be advised they will receive their rebates in the form of a prepaid Visa card.
When customers take advantage of our new Early Upgrade or Early Upgrade Plus options, they are not eligible for upgrade rebate cards. These new upgrade options allow customers to take advantage of upgrades sooner and provide an instant discount, instead of having to wait for rebate cards.
To be eligible for an upgrade rebate card, customers must meet upgrade eligibility requirements.
Current, 1-year contracts: 11 or more active months since last discounted handset purchase.
Current, 2-year contracts: 22 or more active months since last discounted handset purchase.
Rebates on eligible purchases require contract extensions and a $9.99 or higher Data/Messaging feature.
Valid only on FlexPay plans with 1 or 2-year contracts.
Not valid for Even More Plus plans.
Active Months: The number of months in which the account has been in good standing and during which service has not been suspended.
Action Steps
Inform customers that Early Upgrade and Early Upgrade Plus are not eligible for upgrade rebate cards.
Advise customers eligible for rebates that they will receive their rebates in the form of a prepaid Visa card.
"With the purchase of your new handset, you can submit a rebate form to receive your rebate. The rebate will be in the form of a prepaid Visa card that can be used anywhere Visa is accepted. See the rebate form for additional details."
Trackball Replacement Program
[Retail Partner Sales - T-Mobile Employees and Authorized Dealers]
On February 24, T-Mobile will launch a Trackball Replacement program for BlackBerry Pearl 8100/8120 and BlackBerry Curve 8320 customers that are having trackball issues. This program will be available in T-Mobile retail stores only at this time.
Action Step
Refer customers to a T-Mobile retail store after February 24 for further assistance if they come in to your location looking to complete a trackball replacement.
First Connect for Dealers
[Retail Partner Sales]
First Connect for Dealers is an exciting class designed to help on-board and prepare Retail Partners to successfully sell T-Mobile products and services and provide differentiated customer experiences. This four hour class is conducted via the T-Mobile Live Virtual Classroom and covers the following:
Welcome to T-Mobile
Who is T-Mobile?
PCC
Differentiated Handsets
Differentiated Rate Plans
Service Excellence / Selling Skills
Tools and Resources
Customer On-Boarding
The attached flyer contains dates and times for these calls as well as registration details. ADRs should educate their locations about these calls and encourage them to attend.
To successfully be able to attend the training sessions, Retail Partners should have the following:
Computers with high speed Internet connections
The ability to play and hear video segments on the computer using speakers or headset
The use of a fully charged mobile phone to hear the audio portion of the conference call
Printer access to print Participant Workbook.
Action Steps
Share the attached flyer with your locations and encourage them to attend one of the scheduled calls.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved