surfaceview

Android SurfaceView not retaining previously drawn objects

混江龙づ霸主 提交于 2019-12-25 02:30:04
问题 I am experimenting with SurfaceView. My requirement is to simply render a node (simple drawable) first. Then, render more nodes at a later point in time . The snippets of my thread's run method & my doDraw method are below. I am just trying to render 2 different drawables in subsequent passes while retaining both. The problem is it wipes away whatever gets written in 1st pass (see comment in code). How to retain the previously drawn object? public void run() { Canvas canvas; while (_running)

What is the most performant way to draw a rotated bitmap on an Android canvas?

谁都会走 提交于 2019-12-25 01:11:39
问题 I'm working on an app where we hand rolled some star maps. So I don't have to talk in the abstract, here is the app in question: https://play.google.com/store/apps/details?id=com.tw.fireballs If you look on the store listing, you can see we use an image just above the horizon...mostly because it looks super pretty. It's not an issue on lower resolution devices, they don't seem to suffer a huge issue rendering it due to lower number of pixels involved. On a higher resolution device like my HTC

View vs SurfaceView for android game

大憨熊 提交于 2019-12-24 18:06:17
问题 Some people says on SurfaceView, others on View. Which one is the best for a simple android game that uses drawable resources for its entities, and it does NOT uses OpenGL 回答1: I'l recomend you read https://code.google.com/p/beginning-android-games/ Very helpfull for 2D game development and 3D games. And book link http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430230428/ref=sr_1_1?ie=UTF8&s=books&qid=1299265138&sr=8-1 来源: https://stackoverflow.com/questions/17071959/view-vs

Using MySurfaceView with main.xml (android)

烂漫一生 提交于 2019-12-24 12:23:01
问题 i have a simple program on android which is drawing on user touch. here's main activity: public class DrawingActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //setContentView(new MySurfaceView(this)); - this way it works, but // i'm interseted in previous } } this is main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Android - Accessing buttons from SurfaceView

女生的网名这么多〃 提交于 2019-12-24 12:04:10
问题 I am currently working on a simple 2d tower defense game to learn some of the basics of Android game development. To handle my graphics I have a custom object that extends SurfaceView and all of my drawing takes place on the SurfaceView's canvas object. This is all working fine. I'd like my game to have two stages. The "combat" stage and the "building stage". In the building stage, I'm trying to add a button that can be clicked to begin the next combat stage. From my research, it sounds like

Converting YUV to YUV420 Android onPreview

我的未来我决定 提交于 2019-12-24 11:35:53
问题 a)I was wondering what is the difference between YUV and YUV420? b)I want to use the raw frames from Camera and convert them into YUV420 in real time. What is the fastest way to do this? I used bitmap factory to convert from yuv to jpg and I used onDraw() method to draw the bitmap. However, this takes some time to process. What is the best alternative to do the conversion if I want converting from YUV to YUV420? 回答1: I found a very straight forward way to convert from NV12 to YV12/YUV 420.

Best way to draw an image dynamically

谁说我不能喝 提交于 2019-12-24 10:15:48
问题 I'm creating an android app that has to draw a map of an ambient that i have explored with laserscans. I have e text file with all my data like: index x y path 0 0 0 path 1 1 0 path 2 2 0 ...etc obstacle 0 10 10 obstacle 1 10 22 ..etc so I have xy coordinates of where I've been and xy of obstacles I've seen. I have a thread that reads the data from the text file and stores that data in a list . Another thread reads that list and draws all the points that are put in the list until that moment

Removing Title Bar in Android 2.3 (Gingerbread) causes problem with SurfaceView

我们两清 提交于 2019-12-24 09:05:42
问题 Anyone experiencing a problem with their app in Gingerbread? -- if you use requestWindowFeature(Window.FEATURE_NO_TITLE); And you switch to another window, when you come back it changes the dimensions of the surfaceview. For now, I've put the titlebar back in to work around this issue. Thanks for any help Mark 回答1: Yes, we too have experienced this after updating to Android 2.3.4. To fix it in our apps we eliminated the requestWindowFeature(Window.FEATURE_NO_TITLE); in our apps and then

Refresh SurfaceView-->Canvas on OnClickListener Android

折月煮酒 提交于 2019-12-24 08:49:10
问题 I would like each time I press one of the buttons the rectangles on the screen to change position. Or the entire SurfaceView to refresh. The app seems to run but the rectangles do not change position with the counter. Thank you very much. Hare is the xml code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <SurfaceView android:id="@+id/surface"

Android: How get error of Media Player and use it?

眉间皱痕 提交于 2019-12-24 08:16:04
问题 I use SurfaceView for video player If in stream not load video , in logcat view error info(701,0) How get info(701,0) and use it ? Sample : if(error == 701){ .... } 回答1: Yes, you could use setOnErrorListener(..) to your VideoView and handle the errors there. Here is an example: mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { switch(what){ case MediaPlayer.MEDIA_ERROR_UNKNOWN: // handle MEDIA_ERROR