How i can control button input android? i am android programmer and i want control button input in android for example i made a game that when you press back button in android mobile nothing happens but i want quite from game. This is how you can use the android back button in Unity games. In C void Update() if (Application.platform RuntimePlatform.Android) if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit() or in JS function Update() if (Application.platform RuntimePlatform.Android) if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit() but how i can contorl other buttons


Can I include PCM audio data in a commercial application? For certain reasons, I need raw audio data in my application. I would convert certain sounds to a PCM format (at development time), and store amp load these PCM files in my game. PCM stands for Pulse Code Modulation, and as far as I can see, it is a representation of signal, and thus cannot be patented by anyone. Only formats can be patented I suppose (e.g. WAV, which relies on PCM), but PCM sequence of bits cannot be. So if I include PCM data in my application package, I don't violate any patent, do I? I'm developing for Android, by the way.


Android OpenGL ES RENDERMODE WHEN DIRTY implementation I am trying to understand RENDERMODE WHEN DIRTY so that I could save battery life wherever possible.. I made this sample application so that GlSurfaceView is updated with random color only when the random number temp is greater than 50... If the value of temp is less than 50, I want it to retain the last random color.. But in this code sample, it is not retaining it but making the screen go black forever! Basically I want to know if my implementation of RENDERMODE WHEN DIRTY correct... package com.blob.blob import java.util.Random import javax.microedition.khronos.egl.EGLConfig import javax.microedition.khronos.opengles.GL10 import android.app.Activity import android.opengl.GLSurfaceView import android.opengl.GLSurfaceView.Renderer import android.os.Bundle import android.util.Log public class OpenGLActivity extends Activity implements Renderer GLSurfaceView glView Random rand Override public void onCreate(Bundle s) super.onCreate(s) glView new GLSurfaceView(this) glView.setRenderer(this) glView.setRenderMode(GLSurfaceView.RENDERMODE WHEN DIRTY) rand new Random() setContentView(glView) public void onDrawFrame(GL10 gl) int temp rand.nextInt(100) if(temp gt 50) glView.requestRender() gl.glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1) gl.glClear(GL10.GL COLOR BUFFER BIT) public void onSurfaceChanged(GL10 gl, int width, int height) Log.d("OpenglTest", "Surface Changed") public void onSurfaceCreated(GL10 gl, EGLConfig config) Log.d("OpenglTest", "Surface Created") public void onPause() super.onPause() glView.onPause() public void onResume() super.onResume() glView.onResume()


LibGDX Swipe Detection Left and Right I have displayed an image at the center of the screen with libgdx. If I swipe left, the image should move to the left and, if I swipe right, image should move to the right. Subsequent swipes to the left should move the image left. The same should happen for right. I used GestureListener. It works to some extent in the sense if I swipe left first image moves left. But after that if I try to swipe right the image still moves left. So how do I implement the expected behavior? class MyGestureListener implements GestureListener Override public boolean fling(float velocityX, float velocityY, int button) if (velocityX gt 0) iX 20 else iX 20 System.out.println("iX " iX) return true ... Gdx.input.setInputProcessor(new GestureDetector(0.0f, 0.0f, 0.0f, 5f, new MyGestureListener())) ... batch.draw(splashTexture, iX, iY)


Image Buttons Have Low Resolution Quality I'm using Synfig Animator to draw my animations for my android game I'm also using Android Studio to write the code for it, However. On testing, the images that i'm using looks very bad and unfocused even though i made them on a high resolution, I've tried to change the resolution of it but it didn't work! and when i change the size it just get bigger and stay the same.. How can i fix this problem? i need to have perfect animations for my game.


AndEngine Sprite position I had noticed the AndEngine a few days ago, and I tried to create basic game with a few Sprites.Sure, the engine makes the development process much more easier.However I found the sprite lacking a major functionally Whenever there is a need to refer to the position of an Sprite the engine manipulates the position based on the top left corner of sprite,this is not the best thing because there is a need to subtract add the width height to its position in order to refer to its center.However when we refer to he scale of the Sprite it scaled according to its center point (which is great) I find it very confusing to refer to its position each time differently.I solved that by extending the Sprite class and implementing my methods of setCenter and getCenter, I guess that not the best way to do so. Do you have any suggestion?


Is there a way to determine Android physical screen size? We're currently porting our games to Android, and would like to be able to release a universal build for tablets and phones. Is there a way to determine the actual screen size or DPI in order to adjust the size of interface elements accordingly? It took a fair bit of research. Here's what we have tried using UnityEngine public class DisplayMetricsAndroid The logical density of the display public static float Density get protected set The screen density expressed as dots per inch public static int DensityDPI get protected set The absolute height of the display in pixels public static int HeightPixels get protected set The absolute width of the display in pixels public static int WidthPixels get protected set A scaling factor for fonts displayed on the display public static float ScaledDensity get protected set The exact physical pixels per inch of the screen in the X dimension public static float XDPI get protected set The exact physical pixels per inch of the screen in the Y dimension public static float YDPI get protected set static DisplayMetricsAndroid() Early out if we're not on an Android device if (Application.platform ! RuntimePlatform.Android) return The following is equivalent to this Java code metricsInstance new DisplayMetrics() UnityPlayer.currentActivity.getWindowManager().getDefaultDisplay().getMetrics(metricsInstance) ... which is pretty much equivalent to the code on this page http developer.android.com reference android util DisplayMetrics.html using ( AndroidJavaClass unityPlayerClass new AndroidJavaClass("com.unity3d.player.UnityPlayer"), metricsClass new AndroidJavaClass("android.util.DisplayMetrics") ) using ( AndroidJavaObject metricsInstance new AndroidJavaObject("android.util.DisplayMetrics"), activityInstance unityPlayerClass.GetStatic lt AndroidJavaObject gt ("currentActivity"), windowManagerInstance activityInstance.Call lt AndroidJavaObject gt ("getWindowManager"), displayInstance windowManagerInstance.Call lt AndroidJavaObject gt ("getDefaultDisplay") ) displayInstance.Call("getMetrics", metricsInstance) Density metricsInstance.Get lt float gt ("density") DensityDPI metricsInstance.Get lt int gt ("densityDpi") HeightPixels metricsInstance.Get lt int gt ("heightPixels") WidthPixels metricsInstance.Get lt int gt ("widthPixels") ScaledDensity metricsInstance.Get lt float gt ("scaledDensity") XDPI metricsInstance.Get lt float gt ("xdpi") YDPI metricsInstance.Get lt float gt ("ydpi")


LibGDX with SoundPool I'm developing a game for Android using LibGDX in Android Studio. I recently found out that some sounds in my game fail to play. I noticed that every time a sound fails to play, these are the logs 04 12 10 49 51.784 24234 24283 com.gadarts.parashoot.android E AudioTrack AudioFlinger could not create track, status 12 04 12 10 49 51.785 24234 24283 com.gadarts.parashoot.android E SoundPool Error creating AudioTrack 04 12 10 49 52.503 24234 24283 com.gadarts.parashoot.android W AudioTrack AUDIO OUTPUT FLAG FAST denied by client transfer 4, track 44100 Hz, output 48000 Hz This is the code I use to play the sounds public long playSound(SFX fileName, boolean loop, float volume, boolean randomPitch) if (GameSettings.SOUND TOGGLE) try Sound sound prepareSound(fileName) if (randomPitch amp amp GameSettings.SOUND RANDOM PITCH) return setRandomPitch(loop, sound, volume) if (loop) return sound.loop(volume) else return sound.play(volume) catch (GdxRuntimeException e) e.printStackTrace() return 1 private Sound prepareSound(SFX soundFile) throws GdxRuntimeException try String soundPath SFX.fileAttribute.SFX FOLDER NAME.getValue() " " SFX.fileAttribute.SOUNDS FOLDER NAME.getValue() " " soundFile.getParentDir().getValue() " " soundFile.getValue() "." soundFile.getFormat().getValue() Sound sound if (!sounds.containsKey(soundFile.getValue())) sound Main.getAssetsManager().get(soundPath, Sound.class) sounds.put(soundFile.getValue(), sound) else sound sounds.get(soundFile.getValue()) if (sound null) throw new GdxRuntimeException("preparing sound failed sound not found.") return sound catch (GdxRuntimeException e) throw e The sound files are in WAV format. Any ideas how to fix it? Thanks in advance! Update I've found out that this problem appears only on my Nexus 5X. I tried it on Xiaomi Redmi Note 4X and it didn't happen.


android game performance regarding timers Im new to the game dev world and I have a tendancy to over simplify my code, and sometimes this costs me alot fo memory. Im using a custom TimerTask that looks like this public class Task extends TimerTask private MainGamePanel panel public Task(MainGamePanel panel) this.panel panel When the timer executes, this code is run. public void run() panel.createEnemies() this task calls this method from my view public void createEnemies() Bitmap bmp BitmapFactory.decodeResource(getResources(), R.drawable.female) if(enemyCounter lt 24) enemies.add(new Enemy(bmp, this)) enemyCounter Since I call this in the onCreate method instead of in my views contructor (because My enemies need to get width and height of view). Im wondering if this will work when I have multiple levels in game (start a new intent). And if this kind of timer really is the best way to add a delay between the spawning time of my enemies performance wise. adding code for my timer if any1 came here cus they dont understand timers private Timer timer1 new Timer() private long delay1 5 1000 5 sec delay public void surfaceCreated(SurfaceHolder holder) timer1.schedule(new Task(this), 0, delay1) I call my timer and add the delay thread.setRunning(true) thread.start()


Making a Collision Detection for ImageViews I'm trying to make a collision detection system for two ImageViews, but I can't seem to figure it out. I've tried doing several things from StackOverflow and other places, but they don't work. One ImageView stays still and the other moves toward it (it's animated, not a sprite). They don't do anything when the collide, though. Do I need to make them sprites or drawables on a canvas or something?


What external 2d animation formats can I use in android? For an artist who won't be dealing directly with the code, what formats for 2d animation could they use that would be portable into an android game? In my particular case there are no collision requirements or anything, just need to be able to place the animation on screen at a specific point.


Saving an interface instance into a Bundle All I've have an interface that allows me to switch between different scenes in my Android game. When the home key is pressed, I am saving all of my states (score, sprite positions etc) into a Bundle. When re launching, I am restoring all my states and all is OK however, I can't figure out how to save my 'Scene', thus when I return, it always starts at the default screen which is the 'Main Menu'. How would I go about saving my 'Scene' (into a Bundle)? Code import android.view.MotionEvent public interface Scene void render() void updateLogic() boolean onTouchEvent(MotionEvent event) I assume the interface is the relevant piece of code which is why I've posted that snippet. I set my scene like so ('options' is an object of my Options class which extends MainMenu (Another custom class) which, in turn implements the interface 'Scene') SceneManager.getInstance().setCurrentScene(options) Current scene is optionscreen


Programatically find out which app store install came from? Background In my app, I have a 'rate me' button. It follows the usual path user clicks in, it starts an intent and opens the app's listing on the Play Store. All well and good. Now I wish to try to distribute my app via different app stores (Amazon for example), so obviously, if the user hits the 'rate me' button I don't want it to take the user to the Google Play Store but to whatever store they got it from. APK For each store This is possible, true, but I think it would be a complete nightmare to manage (like creating a new APK for each store every time I issue a new update. So I'm looking for something like this pseudo code if(rate me button pressed) if (from Google Play Store) Go to Google Play Store else if (from Amazon Store) Go to Amazon Store And so on....... I'm guessing there is a way (that some apps must surely use) but I have no idea how to go about it.


Can i use Soccer football team names in my web, iphone and android apps? If i don't use logos, player names, sponsors or any images can i use team names in a for profit app? The reason i mention these is that i have seen countless references to images and badges but not the name in text format only. Eg print the league table or show a fixtures list or show some user stats in relation to a team name in the app. I read that a court has ruled in 2012 that fixture lists are not copyright able as they involve pure scheduling logic and no artistic or innovative value. Also i know that logos, shield, images, player names and images etc are copyright able. Do team names fall under fair use if it is purely the team name in a fixture list or in a list or teams?


How do I generate a level randomly? I am currently hard coding 10 different instances like the code below, but but I'd like to create many more. Instead of having the same layout for the new level, I was wondering if there is anyway to generate a random X value for each block (this will be how far into the level it is). A level 100,000 pixels wide would be good enough but if anyone knows a system to make the level go on and on, I'd like to know that too. This is basically how I define a block now (with irrelevant code removed) block new Block(R.drawable.block, 400, platformheight) block2 new Block(R.drawable.block, 600, platformheight) block3 new Block(R.drawable.block, 750, platformheight) The 400 is the X position, which I'd like to place randomly through the level, the platformheight variable defines the Y position which I don't want to change.


Sprite drag drop andengine How to drag an andEngine sprite anywhere on the phone screen? I have written this code in onAreaTouched function of IOnAreaTouchListener interface which is implemented in my activity, but its not working public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) TODO Auto generated method stub Log.v(TAG,"Sprite Touched ") secondSprite new Sprite( CAMERA WIDTH 2, CAMERA HEIGHT 2, playerTextureRegion, this.getVertexBufferObjectManager()) Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) secondSprite.setPosition(pSceneTouchEvent.getX(), pSceneTouchEvent.getY()) System.out.println(String.format("spriteB fx f", pSceneTouchEvent.getX(), pSceneTouchEvent.getY())) return true scene.registerTouchArea(secondSprite) return true


Marmalade SDK views navigation concepts I want to develop a simple multi Activity Android game using Marmalade SDK. I looked at the SDK samples and found that most of them are a single view (Android Activity) apps. The Navigation model in Android is a stack like model where views are pushed and popped. I can't find whether Marmalade has a similar model or it uses a different approach. would you please explain this to me and provide tutorials and samples to navigation in Marmalade if possible ? Thanks


Moving sprites based on Delta time consistent movement across all devices with different resolutions This is the formula I am currently using to move my sprites across the screen Examples below only deal with X coordinates to keeps things as short as possible. Initial variable declarations float frames per second 30 Set this to target frames per second, 30 for this example. float dt 1 frames per second Delta float spriteXGrid Sprite's position on a grid (grid can be any explicit value, I use something simple like 800 x 600) float spriteXScreen Sprite's actual final position in screen coordinates float spriteXTime 5 Time variable. This is in seconds and is the amount of time the sprite should take to traverse the screen float spriteXVel 1 spriteXTime Velocity value used in conjunction with time value to calculate new position To set my sprite's initial position I simply do this spriteXGrid (pos 800) Where pos is the position on the grid (0 800) and 800 is the grid size that I chose to work with. spriteXScreen spriteXGrid width To convert to actual screen coordinates where width is the actual width of the device currently running on. Then to move my sprite, I do this spriteXGrid spriteXGrid (spriteXVel dt) Update sprite's position on the grid spriteXScreen spriteXGrid width And convert to screen coordinates (again, width is the screen width of the current device) Then I just use the spriteXScreen variable to plot the sprite, something like sprite.drawSprite(spriteXScreen,0) this is from a custom class I wrote that takes in sprite's x and y coordinate and draws it there. My question is, is there an easier way I can do this?! It's a nightmare to manage when it comes to collision detection etc.... because, you have 2 different coordinates, the 'screen' one (which I would describe as 'superficial'), and the 'grid' one which is needed for all the good stuff, and is a nightmare to actually work out and work with. is there anyway I can just do something like spriteXScreen 'some value' Which would allow my sprite to move across the screen in the same amount of time on all devices? (I mean I can't just say move it by 1 pixel, because if I move 400 pixels in say 5 seconds on a 400 pixel wide screen, the sprite will have passed the whole screen in those 5 seconds, but on an 800 pixel wide screen it would have only passed halfway in the same amount of time). The whole business of have a 'grid' coordinate and having to convert it to a 'screen' coordinate is extremely irritating and I'm wondering if I'm doing this all wrong....? Suggestions and solutions would be very welcome


how to render small texture on another texture? can anybody help me to render small texture on another texture. i.e I have one background image, when user touches on the screen it should draw small(circle or any object) on it. can anybody suggest me good tutorial to starts with it?


What is wrong with my collision detection code? I want to check collision detection between two bitmaps but I am not getting how to do it. I read several queries and tutorials but didnt get properly. I want to check by their width and height. I have implemented some logic also but not getting where I am doing wrong public boolean collision() for(int i 0 i lt 9 i ) for(int j 0 j lt 14 j ) if(frog.getX() lt x getX() frog.getY() lt y getY() frog.getX() gt x frog.getY() gt y) if(other.getWidth() gt x amp amp other.getWidth() lt x width amp amp gt other.getHeight() gt y amp amp other.getHeight() lt y height) frog.frogShiftDown() return true public void draw(Canvas canvas) canvas.drawBitmap(bmp, x, y,null) carmove() collision()


Structure GameObject States Visual representation Question What is the best data structure for GameObjects that have different states and thus different visuals? The situation is I'm creating a game for mobiles (written in Kotlin, no Engine used). My simplified object structure looks like this I have 2 GameObjects (e.g. Person and Obstacle) Each GameObject might have two different states (IDLE and MOVE) But each state might also have different graphics. For instance depending on the movement direction, the MOVE state might show Bitmap Left or Bitmap Right. Person WALK State Visualisation (WALK, PERSON) draw(bitmap walk left person) My problem is, that I'm really not sure about that structure. Should I make subclasses for each State or a composition? One Visual object for each State (e.g. MOVE, IDLE, TALK) containing all Bitmaps for Person and Obstacle and always showing the right one depending on the parent? Currently it looks like this I have the GameObject. The object has a state that is called in the update() method (e.g. moving a bit to the left). Every State has a "Visual" object that knows its parent State (State WALK). It draws itself related to its states type (e.g. WALK) and considers (if needed) the orientation (left or right). This felt like it keeps structures as abstract as possible but I'm not sure sure thats a good solution because all objects have to keep references to their "parents". So the visuals need a reference to the state (WALK) and to the GameObject (Person) in order to draw the visual for a walking person. Would it be better to create subclases for each State? So I have a class "VISUAL MOVE PERSON", "VISUAL IDLE PERSON", "VISUAL IDLE TREE" ... That seems a lot of redundant code and classes. Is there a common structure for Actions States and their Visual Representation? Especially since I will have many more objects with at least a few different states (IDLE, MOVE, TALK, ...) Should the visuals be part of each state? Or are they independent to each other (e.g. GameObjects have a State and a Visuals object) instead of the "chain of references" shown above?


Real time multiplayer game server development I'm an Android developer, and I want to start developing a real time multiplayer game, like Pocket Legends. Would this type of server be good for a real time multiplayer action game http systembash.com content a simple java udp server and udp client ? I'm absolutly new to server development, so it would be great if you explaind even more about this stuff ...


What's the best way to create animations when doing Android development? I'm trying to create my first Android game and I'm currently trying to figure out (with someone that will do the drawings and another programmer) what the best way to create animation is. (Animations such as a character moving, etc.) At first, the designer said that she could draw objects characters and animate them with flash so she didn't have to draw every single frame of an action. The other programmer and I don't know Flash too much so I suggested extracting all the images from the Flash animation and making them appear one after the other when the animation is to start. He said that would end up taking too much resource on the CPU and I tend to agree, but I don't really see how we're supposed to make smooth animations without it being too hard on the hardware and, if possible, not have the designer draw every single frame on Adobe Illustrator. Can an experienced Android game developper help me balance this out so we can move on to other parts of the game as I have no idea what the best way to create animations is.


Separate renderng thread in Android (OpenGL ES 2.0) I'm used to mainly working with the Canvas SurfaceView API on Android and have recently been learning openGL ES 2.0 With canvas I know that surfaceView gives you the ability to start a new thread to render on, but it doesn't specifically do this for you, so I was creating a new thread and managing that thread when the app was ended paused etc.... However, from what I've read with glSurfaceView it seems that this is actually done for you automatically? Does this mean I don't actually need to manually create start and manage my own rendering thread? (I'm talking specifically about a rendering thread (which could also be used for logic updates) which is separate the main UI thread. Clarification on this matter would be greatly appreciated.


Android canvas.drawColor throws a null object reference I have two nearly identical methods, the first to draw a splash screen while assets are loading, and the second to draw all of the assets to the screen. The first throws a NullPointerException on this line canvas.drawColor(Color.argb(255, 0, 0, 0)) Here is my error Caused by java.lang.NullPointerException Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int)' on a null object reference 10 19 21 54 56.042 18973 18973 ? E AndroidRuntime at com.xyz.123.GameView.drawSplash(GameView.java 76) Here is my code in full package com.xyz.123 import android.content.Context import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.view.MotionEvent import android.view.SurfaceHolder import android.view.SurfaceView public class GameView extends SurfaceView implements Runnable volatile boolean playing Thread gameThread null private Paint paint private Canvas canvas private SurfaceHolder holder private int screenWidth private int screenHeight private Background1ResourceList background1ResourceList private Background background1 private Background background2 private Background background3 private Context context private SplashScreen splashScreen public GameView(Context context, int screenWidth, int screenHeight) super(context) this.context context this.screenWidth screenWidth this.screenHeight screenHeight Initialize our drawing objects holder getHolder() paint new Paint() splashScreen new SplashScreen(context, screenWidth, screenHeight) drawSplash() background1ResourceList new Background1ResourceList() background1 new Background(context, background1ResourceList.getBackgroundResources(), screenWidth, screenHeight, 0.00f, 0.50f) background2 new Background(context, background1ResourceList.getBackgroundResources(), screenWidth, screenHeight, 0.33f, 0.80f) background3 new Background(context, background1ResourceList.getBackgroundResources(), screenWidth, screenHeight, 0.66f, 1.00f) Override public void run() while (playing) update() draw() control() private void update() background1.update() background2.update() background3.update() private synchronized void drawSplash() if (holder.getSurface().isValid()) First we lock the area of memory we will be drawing to holder.getSurface() canvas holder.lockCanvas() rub out the last frame canvas.drawColor(Color.argb(255, 0, 0, 0)) draw the backgrounds splashScreen.draw(canvas, paint) unlock and draw the scene holder.unlockCanvasAndPost(canvas) else System.out.println("surface not valid") private synchronized void draw() if (holder.getSurface().isValid()) First we lock the area of memory we will be drawing to canvas holder.lockCanvas() rub out the last frame canvas.drawColor(Color.argb(255, 0, 0, 0)) draw the backgrounds background1.draw(canvas, paint) background2.draw(canvas, paint) background3.draw(canvas, paint) holder.unlockCanvasAndPost(canvas) public void pause() playing false try gameThread.join() catch (InterruptedException e) public void resume() playing true gameThread new Thread(this) gameThread.start()


Max Row and Col for Animating Sprite in Andengine I want to animate a Sprite in Andengine , I have used the following this.mSnapdragonTextureRegion BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this,"arrow.png", 10, 10) As show above in code its array is 10x10 that means I have 100 images to be animated, here is the image (I had individual image and joined it online so I created image below) My issue is if I place this code and image it show black patch instead of animated image, i hv tried with 2x3, 4x2 animated sprite that is working fine . Is my issue because of 10x10 ? what is the max row and col I can place to animate a Sprite in Above Code Here is my output


Selling Android apps from Android Market unsupported countries I am in Latvia (which the Android market doesn't support as a country for selling apps from), and I am thinking about the best way of monetizing my app. So far I've come up with these options Pretend I am from a supported country. Get a bank account there, etc. Use PayPal for in app purchases. The player gets, say, the first 10 levels for free, but is then asked to pay 0.99 for the rest of the game. Downside Players might not feel comfortable entering PayPal details into an app. Android market might not like it either. Making the app free and earning money through advertising. Let's do some calculation here Say I get 1M free downloads, each user during his playtime would see 10 banners, so 10m 1000 0.3 is about 33k if we use AdMob with their 0.3 per 1000 impressions. On the other hand, if we use PayPal and in app purchases, we need a 3 conversion rate to beat this.. What should I do? Edit From what I just read all over the net, it looks like advertisers will change their eCPM price a lot without telling you. Using in app PayPal purchases at least allow you to monitor the cash flow.


AndEngine Scoreloop java.lang.IllegalStateException you are not calling from the main thread context I am a very novice android developer but also created a game using andEngine successfully. Now I want to integrate Scoreloop and everything is fine with Leaderboard view and TOS view, except I am having hard time submitting scores from a game scene. I implemented OnScoreSubmitObserver in the main BaseGameActivity (GameActivity). I used the following line inside the onCreateEngineOptions method ScoreloopManagerSingleton.get().setOnScoreSubmitObserver(this) I also declared the override method perfectly inside GameActivity as mentioned in the scoreloop tutorial Override public void onScoreSubmit(int status, Exception error) TODO Auto generated method stub Calls the ShowResultOverlayActivity. Make sure you have modified the AndroidManifest.xml to reference this overlay class. startActivity(new Intent(this, ShowResultOverlayActivity.class)) Now I want to submit score from inside a scene using the following line ScoreloopManagerSingleton.get().onGamePlayEnded(score, null) But this shows the following error java.lang.IllegalStateException you are not calling from the main thread context I also tried implementing OnScoreSubmitObserver on the scene class and tried calling each line mentioned above inside the scene class using "activity" instead of "this", as "activity" is an instance of the GameActivity. but it also shows the same error. Please help.


How do you calculate the rate of rotation using the accelerometer values in Android for a particular axis? I am developing a simple game which involves a character moving up and down only along the Y axis. Currently I am using the accelerometer readings to change the Y velocity of the character. The game works fine but the biggest problem is that you have to keep the device horizontal in order to play the game properly. What I really want is to change the characters Y velocity only when there is a change in the rate of rotation along the Y axis. I need to be able to translate this rate of change into the Y velocity of the character. In this way it will not matter how much the device is tilted and the user can play the game while holding the device normally. Since the accelerometer is mandatory in every device, therefore older devices can run my game I want to be able to calculate this rate of change using the data retrieved from the accelerometer. I found a link which explains how to get pitch and roll from accelerometer data. I used the exact code and came up with this, final double alpha 0.5 double fXg 0 double fYg 0 double fZg 0 fXg game.getInput().getAccelX() alpha (fXg (1.0 alpha)) fYg game.getInput().getAccelY() alpha (fYg (1.0 alpha)) fZg game.getInput().getAccelZ() alpha (fZg (1.0 alpha)) double pitch (Math.atan2( fYg, fZg) 180.0) Math.PI double roll (Math.atan2(fXg, Math.sqrt(fYg fYg fZg fZg)) 180.0) Math.PI pitch (pitch gt 0) ? (180 pitch) ( pitch 180) With this piece of code I am unable grasp how to calculate the RATE of change. Am I going in the right direction with this or is this completely different from what I want? Also is it better if I just use the gyroscope instead of relying on the accelerometer? Thanx in advance.


Google Cloud Messaging (GCM) for turn based mobile multiplayer server? I'm designing a multiplayer turn based game for Android (over 3g). I'm thinking the clients will send data to a central server over a socket or http, and receive data via GCM push messaging. I'd like to know if anyone has practical experience with GCM for pushing 'real time' turn data to game clients. What kind of performance and limitations does it have? I'm also considering using a RESTful approach with GAE or Amazon EC2. Any advice about these approaches is appreciated.


how to use texture atlas I am trying to implement texture atlas. 1) I am using the texturepackerGUI and the result is taking 2 files , one png (whicj contains all the images and one .atlas (and not .pack). 2) Now , I want to use the above instead of every seperate image. Right now , I use for example private void loadTextures() bobTexture new Texture(Gdx.files.internal("data images bob 01.png")) blockTexture new Texture(Gdx.files.internal("data images block.png")) I want to use texture atlas , so instead of the above TextureAtlas atlas atlas new TextureAtlas(Gdx.files.internal("data images bobs")) bobs.atlas Sprite bobsprite atlas.createSprite("bob 01") Sprite blocksprite atlas.createSprite("block") Now,I must initialize TextureAtlas I think because it gives me error "Syntax error on token " ", , expected".I don't know how. 3) I put TexturePacker2 in the android project (MainActivity) ... AndroidApplicationConfiguration cfg new AndroidApplicationConfiguration() cfg.useGL20 true cfg.useAccelerometer false cfg.useCompass false cfg.useWakelock true TexturePacker2.process("my gdx game android assets images ", " my gdx game android assets data", "bobs.atlas") ... The folders inside TexturePacker are ok syntaxed? Or I must remove the "my gdx game android assets "? Thanks!


Scaling and new coordinates based off screen resolution I'm trying to deal with different resolutions on Android devices. Say I have a sprite at X,Y and dimensions W,H. I understand how to properly scale the width and heigh dimensions depending on the screen size, but I am not sure how to properly reposition this sprite so that it exists in the same area that it should. If I simply resize the width and heigh and keep X,Y at the same coordinates, things don't scale well. How do I properly reposition? Multiply the coordinates by the scale as well?


Empty Synchronized method in game loop I am studying the gameloop used in Replica Island to understand a bit about Android game development. The main loop has the below logic... GameThread.java (note the variable names in sample code dont match exact source code) while (!finished) if (objectManager ! null) renderer.waitDrawingComplete() Do more gameloop stuff after drawing is complete... I was curious to see what waitDrawingComplete actually does, but found its just an empty syncrhonized method! I guess it does nothing, am I missing something here? GameRenderer.java line 328 public synchronized void waitDrawingComplete() Source code can be checked out here with SVN if you feel like having a look https code.google.com p replicaisland source checkout


Why do I get this error when setting up Android support for Game Maker? Game Maker asks me to install the Android SDK API 13 for it to work. I opened the SDK Manager and clicked at API 13 but I wasn't able to click the "install packages" button. I clicked at the obsolete and then I was able to install. But when I pressed "Accept Licence" I wasn't able to click install as an error came out Package Google Tv Addon, Android API 13, revision 1 (Obsolete) depends on Missing SDK Platform Android, API 13". Any help would be much appreciated.


openGL ES change the render mode from RENDERMODE WHEN DIRTY to RENDERMODE CONTINUOUSLY on touch i want to change the rendermode from RENDERMODE WHEN DIRTY to RENDERMODE CONTINUOUSLY when i touch the screen. WHAT i Need Initially the object should be stationary. after touching the screen, it should move automatically. The motion of my object is a projectile motion ans it is working fine. what i get Force close and a NULL pointer exception. My code public class BallThrowGLSurfaceView extends GLSurfaceView MyRender renderObj Context context GLSurfaceView glView public BallThrowGLSurfaceView(Context context) super(context) TODO Auto generated constructor stub renderObj new MyRender(context) this.setRenderer( renderObj) this.setRenderMode(RENDERMODE WHEN DIRTY) this.requestFocus() this.setFocusableInTouchMode(true) glView new GLSurfaceView(context.getApplicationContext()) Override public boolean onTouchEvent(MotionEvent event) TODO Auto generated method stub if (event ! null) if (event.getAction() MotionEvent.ACTION DOWN) if ( renderObj ! null) Log.i("renderObj", renderObj "lll") Ensure we call switchMode() on the OpenGL thread. queueEvent() is a method of GLSurfaceView that will do this for us. queueEvent(new Runnable() public void run() glView.setRenderMode(RENDERMODE CONTINUOUSLY) ) return true return super.onTouchEvent(event) PS i know that i am making some silly mistakes in this, but cannot figure out what it really is.


LibGDX RPG walking animation I've been trying to nail down a walking animation with libGDX. I'm making an RPG with the character that can move up, down, left, and right. I have this movement in a spritesheet. I've been following a youtube tutorial called Java Tiled Map Game which can be found here http www.youtube.com watch?v qik60F5I6J4 He does a better job then some of explaining what the code does but he glosses over the part where he gets his character to do a walking animation (by which I mean he doesn't show it at all). I then moved to the tutorial found here http obviam.net index.php getting started in android game development with libgdx tutorial part 2 animation But this tutorial tells exactly what needs to be done in regular words and then just gives a block of code. I already know what I need to do in regular words but I'm not trying to learn english but programming which is a completely different language. I'm sure I could copy and paste that code and edit it to do what I need but I wouldn't understand HOW it works only THAT it works. I want to know the how of it all. I'm new to libGDX and this is my first RPG game. I really want learn how to do it myself instead of relying on others. My question is simply this Do you know of a tutorial which shows and (more importantly) explains how to do a simple walking animation? I'm hoping you can supply one for me.


LibGDX music doesn't play anymore after x times In my App I added two sounds, the first is played when the gamescreen start the second when the game is going to game Over screen. Everything works fine but after about 12 13 games the second sound isn't played and until the player close completly the app and open it again every sound isn't played. How to solve? Errors 05 24 09 04 29.773 5571 5585 E AudioTrack AudioFlinger could not create track, status 12 05 24 09 04 29.773 5571 5585 E SoundPool Error creating AudioTrack 05 24 09 04 32.421 5571 5585 E MediaPlayer error ( 19, 0) 05 24 09 04 32.421 5571 5571 E MediaPlayer Error ( 19,0)


Getting the height of Keyboard on Android Hi I need to know the height of my keyboard so I can move up some textfield I have in my app. I'm using cocos2D X but the app don't recognize the keyboardWillShow method. Thanks


WiFi Game Controller Protocol I'm wanting to use mobile devices to control a game. I'd like to use an industry standard protocol for wifi game controllers rather than roll my own, but have been unable to find any standard. Does there exist any industry standard wifi game controller protocol? Is there some unofficial protocol many implement, preferably with quality Android iPhone client implementations available?


How could an offline app store images so that they aren't trivially discoverable? There is an app I play which has lots of images. I have reverse engineered the app but couldn't find the images in the APK. The app is an offline app so it doesnt retrieve images from a server. My question is, then, where did this app store its images? I'd like to achieve the same level of protection (to deter casual observation of the images).


Loading Bitmap by name in Android Currently, I'm loading images as follows sampleimage BitmapFactory.decodeResource(context.getResources(), R.drawable.sampleimage) This automatically chooses the correct image from the drawable hdpi, drawable mdpi or drawable ldpi folders. How can I load the bitmap using the image name as the string "sampleimage.png"?


how to play a video with Android or AndEngine I don't know if it's possible to show a video like the videos in Angry Birds (Something in Flash or another format) in middle of a game with Android or AndEngine or are they animations what they are made with Sprites and a more programming process?? How do they show those videos?


Adding Libxml2 to an Android project under Cocos2D X I am having problems porting Libxml2. I like it because it works under windows like a charm with lt libxml parser.h gt . When I reference the libraries I just cannot find the right path to them, their own references are broken and I don't know how to fiddle with Android.mk What is the procedure?


glGetActiveAttrib on Android NDK In my code base I need to link the vertex declarations from a mesh to the attributes of a shader. To do this I retrieve all the attribute names after linking the shader. I use the following code (with some added debug info since it's not really working) int shaders m ps, m vs if(linkProgram(shaders, 2)) ASSERT(glIsProgram(m program) GL TRUE, "program is invalid") int attrCount 0 GL CHECKED(glGetProgramiv(m program, GL ACTIVE ATTRIBUTES, amp attrCount)) int maxAttrLength 0 GL CHECKED(glGetProgramiv(m program, GL ACTIVE ATTRIBUTE MAX LENGTH, amp maxAttrLength)) LOG INFO("shader", "got d attributes for ' s' ( d) (maxlen d)", attrCount, name, m program, maxAttrLength) m attrs.reserve(attrCount) GLsizei attrLength 1 GLint attrSize 1 GLenum attrType 0 char tmp 256 for(int i 0 i lt attrCount i ) tmp 0 0 GL CHECKED(glGetActiveAttrib(m program, GLuint(i), sizeof(tmp), amp attrLength, amp attrSize, amp attrType, tmp)) LOG INFO("shader", " d d d ' s'", i, attrLength, attrSize, tmp) m attrs.append(String(tmp, attrLength)) GL CHECKED is a macro that calls the function and calls glGetError() to see if something went wrong. This code works perfectly on Windows 7 using ANGLE and gives this this output info shader got 2 attributes for 'static simplecolor.glsl' (3) (maxlen 11) info shader 0 7 1 'a Color' info shader 1 10 1 'a Position' But on my Nexus 7 (1st gen) I get the following (the errors are the output from the GL CHECKED macro) I testgame shader(30865) got 2 attributes for 'static simplecolor.glsl' (3) (maxlen 11) E testgame gl(30865) 'glGetActiveAttrib(m program, GLuint(i), sizeof(tmp), amp attrLength, amp attrSize, amp attrType, tmp)' failed INVALID VALUE jni src .. .. .. .. src Game Asset ShaderAsset.cpp 50 I testgame shader(30865) 0 1 1 '' E testgame gl(30865) 'glGetActiveAttrib(m program, GLuint(i), sizeof(tmp), amp attrLength, amp attrSize, amp attrType, tmp)' failed INVALID VALUE jni src .. .. .. .. src Game Asset ShaderAsset.cpp 50 I testgame shader(30865) 1 1 1 '' I.e. the call to glGetActiveAttrib gives me an INVALID VALUE. The opengl docs says this about the possible errors GL INVALID VALUE is generated if program is not a value generated by OpenGL. This is not the case, I added an ASSERT to make sure glIsProgram(m program) GL TRUE, and it doesn't trigger. GL INVALID OPERATION is generated if program is not a program object. Different error. GL INVALID VALUE is generated if index is greater than or equal to the number of active attribute variables in program. i is 0 and 1, and the number of active attribute variables are 2, so this isn't the case. GL INVALID VALUE is generated if bufSize is less than 0. Well, it's not zero, it's 256. Does anyone have an idea what's causing this? Am I just lucky that it works in ANGLE, or is the nvidia tegra driver wrong?


Alert Dialog Box font color in AndEngine I am developing an app using AndEngine and I am using my own custom theme to use white background theme. My styles.xml file looks like this lt resources gt lt color name "white opaque" gt FFFFFF lt color gt lt color name "pitch black" gt 000000 lt color gt lt style name "AppTheme" parent "android Theme.Light" gt lt item name "android background" gt color white opaque lt item gt lt item name "android windowBackground" gt color white opaque lt item gt lt item name "android colorBackground" gt color white opaque lt item gt lt style gt lt resources gt Everything is working fine except in the dialog box the font color is white and it looks like this How can I change the font color to black for the text?


Cross platform ad hoc local mobile multiplayer I want to implement ad hoc cross platform (iOS, Android, and PC) device discovery for local multiplayer, like this scenario http www.youtube.com watch?v csXYZf2vGdE Multiple players, each with different devices (iOS, Android, PC). One player starts a game. The others can search and automatically discover his game and enter into a local multiplayer match. This would all be done P2P, without any dedicated game servers. Is this possible with current technology?


Why can't I use C routines to load files in Android NDK? I have successfully rendered a triangle with a hard coded shader using NativeActivity of Android NDK. Now I have the requirement to load a shader file. I tried to use fopen but it is returning NULL. I have researched a little bit and found out there's an AAssetManager which I can use. I want to know why fopen didn't work and why should I use AAssetManager to load files?


How do I pause Andengine, but still get input? In my game when I pause the game, I'd like to display three options (Resume, Restart and Menu) so I did this after calling mEngine.stop() Sprite resume new Sprite(CAMERA WIDTH 2, CAMERA HEIGHT 2, RM.resume, vertex) Override public boolean onAreaTouched(TouchEvent event, float pTouchAreaLocalX, float pTouchAreaLocalY) if(event.isActionDown()) this.setScale(1.1f) Log.i("Click","Click") return super.onAreaTouched(event, pTouchAreaLocalX, pTouchAreaLocalY) But the Log "Click" never display. So I tried to do this with the Engine active and the Log displays correctly. How can I stop my game (Modifier, Physics, Score) without using the mEngine.stop() method ?


OpenGL self test in a mobile game I've made an Android game that uses no custom game engine. It renders using OpenGL ES 2.0 and optionally uses some extensions for optimization or extra effects. Over the time I have dealt with various issues in OpenGL drivers, I had to implement workarounds or disable usage of some features on some devices. I am still getting reports from users that something does not render correctly on their device, but in most cases I have no way to debug it as it is happening on some strange device that I don't have. I am using AWS device farm for testing and all the devices there render the game correctly... So I have come with an idea to implement some kind of self test. It would run shortly after the first start and render off screen some samples that test the shaders and features I use. The images would be compared to how they are supposed to look like. (I know the comparison must have some tolerance.) If it detects a mismatch, it could send me screenshots and detailed information about the OpenGL environment. Possibly it could even self heal by disabling some features and trying again. Was something like that already done in a (mobile) game? Are there any caveats I should be aware of?


Play Protect Submission I just filled submission form for google play protect for my new developed game. the problem is with URL download link. I used file.io to generate a direct download link. it worked fine for the first time but now error 404 for "not found" is shown. I re submit a new form with same information but different URL to download my APK (I used DropBox to generate direct link and bit.ly for shortening the link) but google told me via email that it doesn't need to re submit. I know that the the process for accepting my game could last for 7 10 days. what do you suggest?


Sounds make Andengine Scene junky I have a GameScene which has a character (animated sprite), AutoParallaxBackground background with quite large textures and no more than 3 other items attached to the scene at a time, previous 3 items are dispose() ed accordingly, background music and item sounds. Background music is instantiated with MusicFactory, Sounds are played on SoundPool. In between switching these scene we are loading resources asynchronously, reading the streams and instantiation is done in AsyncTask and the loading textures to the hardware is done on UpdateThread GLThread. If I turn off the background music, this starts to happen totally random. I'm experiencing scene junking on at first flow MenuScene 1st Stage (GameScene). After a while lag does not happen, rather than occasionally or random. Junk is happening when aforementioned 3 items are attached on the Scene and a sound is played along, note that background music is playing at the same time. Detaching previous 3 items is "optimized" to reduce GC calling almost perfectly. When the lag occurs GC EXPLICIT is showed in the logcat. What I have tried Playing the sounds and music on different thread, IntentService, dedicated Service. Reduced calls to mScene.detachChild(child) and other scene methods to avoid iterations over children of the scene. Detaching IEntitys with matcher to avoid iteration. Inspected sound files' integrity with ffmpeg for possible errors Could .dispose(), unloading the textures from hardware or detachChild() causing this junk? Could be marked object for GC from the async tasks be causing this? What else could be contributing to this issue?


Loading large bitmaps in Android In a few games in the Android Market Google Play Store, huge bitmaps are drawn onto the screen. For example, the game Unicorn Dash and Robot Unicorn Attack I'm assuming the entire island (which is multiple screens long) is loaded into memory. With probably around 10 different islands, how can something like this be possible? I've attempted to do something similar in one of my games, but I always ran out of memory. The bitmaps are (estimated) at around 2000px x 500px at the largest which comes out to about 4mb each uncompressed? If you had 10 of them it would require 40mb of memory! So obviously I'm missing something. Is it plausible to be loading and unloading bitmaps into memory while the game runs? Or is there some other technique that I'm not aware of? EDIT I extracted the images from Robot Unicorn Attack and saw that they were indeed whole images (not split up) of around 2000 500 pixels.


How can I access bitmaps created in another activity? I am currently loading my game bitmaps when the user presses 'start' in my animated splash screen activity (the first launch activity) and the app progresses from my this activity to the main game activity, This is causing choppy animation in the splashscreen while it loads creates the bitmaps for the new activity. I've been told that I should load all my bitmaps in one go at the very beginning. However, I can't work out how to do this could anyone please point me in the right direction? I have 2 activities, a splash screen and the main game. Each consist of a class that extends activity and a class that extends SurfaceView (with an inner class for the rendering logic updating). So, for example at the moment I am creating my bitmaps in the constructor of my SurfaceView class like so public class OptionsScreen extends SurfaceView implements SurfaceHolder.Callback Create variables here public OptionsScreen(Context context) Create bitmaps here public void intialise() This method is called from onCreate() of corresponding application context Create scaled bitmaps here (from bitmaps previously created)


Make a sprite jump to a certain direction in libGDX I was wondering how you can make a sprite jump to a certain direction in libGDX just like the brick does in the famous mobile game "Amazing Brick' I want to make my sprite jump up a bit to the right when I tap the right part of the phone and make it jump up but to the left direction when I tap on the left part of my phone. I am using libGDX on android studio and I am on a beginner level, trying to develop a unique game for android. Plz help. Thanks in advance. o


How do i update opengl lightning equation in my fragment shader to make my texture less glossy and more like a fabric I built a model in blender, and am currently trying to import it into my android app using assimp together with opengl, i dont have any issues with the importing but my goal is to make the object look realistic as possible, and this is where my problem lies...I have implemented normal mapping using both the diffuse and normals of my texture but after rendering it the objects looks smooth and glossy, yes the bumps were rendered well and i like it but i need the material to look more like a fabric (cloth textile), please how can i do this? do i need to update my lighting equation or the issue is with my original diffuse texture? Here is my original diffuse texture Here is my rendered model Here's my fragment shader void main() obtain normal from normal map in range 0,1 vec3 normal texture2D( normalMap, textureCoords ).xyz transform normal vector to range 1,1 normal normalize(normal 2.0 1.0) this normal is in tangent space get diffuse color vec3 color texture2D( textureSampler, textureCoords ).xyz ambient vec3 ambient 0.1 color diffuse vec3 lightDir normalize(tangentLightPos tangentFragPos) float diff max(dot(lightDir, normal), 0.0) vec3 diffuse diff color specular vec3 viewDir normalize(tangentViewPos tangentFragPos) vec3 reflectDir reflect( lightDir, normal) vec3 halfwayDir normalize(lightDir viewDir) float spec pow(max(dot(normal, halfwayDir), 0.0), 32.0) vec3 specular vec3(0.2) spec gl FragColor vec4(ambient diffuse specular, 1.0) Here's my vertex shader mat3 transpose(mat3 m) return mat3(m 0 0 , m 1 0 , m 2 0 , m 0 1 , m 1 1 , m 2 1 , m 0 2 , m 1 2 , m 2 2 ) void main() gl Position mvpMat vec4(vertexPosition, 1.0) vec3 fragPos vec3(model vec4(vertexPosition,1.0)) vec3 T normalize(normalMatrix tangent) vec3 N normalize(normalMatrix normal) T normalize(T dot(T, N) N) vec3 B cross(N, T) mat3 TBN transpose(mat3(T, B, N)) values for fragment shader tangentLightPos TBN lightPos tangentViewPos TBN viewPos tangentFragPos TBN fragPos textureCoords vertexUV


Playing with hashmap in drawing I'm developing a game in Java for Android, using LibGDX. In my render(), between the batch.begin() and batch.end() I'm running through all the game objects and draw them. Every game object is stored in a list, which that list is stored inside a hash map. I iterate through this hash map, getting every list and going through that list, like this batch.begin() Iterator it objectsMap.entrySet().iterator() while (it.hasNext()) Map.Entry pair (Map.Entry) it.next() Array list (Array) pair.getValue() for (int i 0 i lt list.size i ) GameObject object (GameObject) list.get(i) drawObject(object) batch.end() My drawObject() code private void drawObject(GameObject object, float x, float y) if (object null) return if (object.getVisibility()) TextureAtlas.AtlasRegion currentFrame object.getCurrentFrame() if (currentFrame ! null) float objectAlpha object.getAlpha() Color color batch.getColor() if (objectAlpha ! 1) color.a object.getAlpha() batch.setColor(color) batch.draw(currentFrame, x object.getOriginX(), y object.getOriginY(), object.getOriginX(), object.getOriginY(), currentFrame.getRegionWidth(), currentFrame.getRegionHeight(), object.scaleX, object.scaleY, object.getSpriteDirection()) color.a 1 batch.setColor(color) A method called setRegion() sets the current animation frames of the object protected void setRegion(String name, float frameDuration) currentFrame atlas.findRegion(name, 0) if (currentFrame null) currentFrame atlas.findRegion(name, 1) width currentFrame.getRegionWidth() height currentFrame.getRegionHeight() animationStateTime 0 animation new Animation(frameDuration, atlas.findRegions(name), Animation.PlayMode.LOOP) And in the update() of the objects this is called currentFrame (TextureAtlas.AtlasRegion) animation.getKeyFrame(animationStateTime, isLooping) The getCurrentFrame() method only returns currentFrame variable. The alpha is a field with a value between 0 and 1. (getAlpha() returns only the field) My question is that considered a "heavy" activity? Can this be a significant impact on the FPS values? Because I'm running my game on old devices (like Galaxy S2) and the FPS can get pretty low values. I'm trying to find the cause to it. I used to have a reference to every list but with the time I realized I'm going to have too much lists, so I decided to do it like this. Maybe you know a better way of holding references to all game objects? Thanks!


In Android, is saving game data in a binary file a good approach? I am nearly finished with my Android game, but I want to make sure my save format is good. I am working on a fairly large game, so data such as high scores, stars, etc. are stored for around 80 levels, along with data for purchased items. Currently I save this data sequentially in a binary file. So when I need to load it, I have to go through all of the previous data to get to the data that I actually need. It seems to work fine, but I question how well this format will hold up for game updates. Is this is a bad approach to take? I considered using SQLite, but after trying to implement it into my game it didn't seem very effective. Updates seem as if they would be even more complicated.


unable to use two gestures simultaneously I have a class implementing gesture listener in libgdx. I want to use longpress gesture in one half of the screen and fling gesture in other part of the screen simultaneously. public class FlingHandler implements GestureDetector.GestureListener GameWorld world Bmw bmw private float w,h,xunit, yunit private float spd 1 private float xtouch 0, ytouch 0 private float xVel 0, yVel 0 private int p 0 public FlingHandler(GameWorld world) this.world world w SS.WIDTH h SS.HEIGHT xunit SS.x yunit SS.y bmw world.getBmw() public void update(float delta) updateLongpress(delta) public void updateLongpress(float delta) if(longPress(xtouch,ytouch) true amp amp world.getBmw().isDead() false) if(spd lt 1600 amp amp Gdx.input.isTouched()) spd 0.9f delta Gdx.app.log("speed ","increasing" spd) else if(longPress(xtouch,ytouch) false amp amp world.getBmw().isDead() false) if(spd gt 1 ) spd 8f delta Gdx.app.log("speed ","decreasing" spd) else Override public boolean fling(float velocityX, float velocityY, int button) xVel velocityX yVel velocityY xtouch Gdx.input.getX() ytouch Gdx.input.getY() p button if(xtouch gt SS.WIDTH 2 amp amp world.getBmw().isDead() false) if (Math.abs(xVel) gt Math.abs(yVel)) if (xVel gt 0) if (world.getBmw().getPosition().x lt 8 xunit) world.getBmw().getPosition().x 4 xunit else if (xVel lt 0) if (world.getBmw().getPosition().x gt 7 xunit) world.getBmw().getPosition().x 4 xunit else return true else return false Override public boolean longPress(float x, float y) xtouch Gdx.input.getX() ytouch Gdx.input.getY() if(xtouch lt SS.WIDTH 2 amp amp world.getBmw().isDead() false) return true else if (xtouch gt SS.WIDTH 2) return false else return false


Is it possible to overlay EditText box on a GLSurfaceView on Android? I am trying to add a "PlayerName" box on top of a opengl menu background, is this possible? I've tried various layouts, but they don't seem to allow an EditText box to appear on top What is the typical way of doing something like this? Do I need to manually render the text and handle input or is there a better way? It seems like it should be possible to show the EditText on top of the GLSurfaceView somehow.


Sprite drag drop andengine How to drag an andEngine sprite anywhere on the phone screen? I have written this code in onAreaTouched function of IOnAreaTouchListener interface which is implemented in my activity, but its not working public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) TODO Auto generated method stub Log.v(TAG,"Sprite Touched ") secondSprite new Sprite( CAMERA WIDTH 2, CAMERA HEIGHT 2, playerTextureRegion, this.getVertexBufferObjectManager()) Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) secondSprite.setPosition(pSceneTouchEvent.getX(), pSceneTouchEvent.getY()) System.out.println(String.format("spriteB fx f", pSceneTouchEvent.getX(), pSceneTouchEvent.getY())) return true scene.registerTouchArea(secondSprite) return true


How can I use ParallaxBackground in AndEngine? I'm new to game development with AndEngine. I want to add ParallaxBackground but I don't know how to change the background when the player moves. I'm using arrows for moving a player. Now my question is where I write the code parallaxBackground.setParallaxValue(5) ? I have written this line in onAreaTouched method of arrow but it does not work. Code private Camera mCamera private static int CAMERA WIDTH 800 private static int CAMERA HEIGHT 480 private BitmapTextureAtlas bgTexture private ITextureRegion bgTextureRegion Override protected void onCreateResources() BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx ") bgTexture new BitmapTextureAtlas(getTextureManager(),2160,480,TextureOptions.REPEATING BILINEAR) bgTextureRegion BitmapTextureAtlasTextureRegionFactory.createFromAsset(bgTexture, this, "background.png", 0, 0) bgTexture.load() Override protected Scene onCreateScene() this.getEngine().registerUpdateHandler(new FPSLogger()) Scene scene new Scene() scene.setBackground(new Background(Color.BLACK)) final ParallaxBackground parallaxBackground new ParallaxBackground(0, 0, 0) final VertexBufferObjectManager vertexBufferObjectManager this.getVertexBufferObjectManager() parallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA HEIGHT this.bgTextureRegion.getHeight(), this.bgTextureRegion, vertexBufferObjectManager))) scene.setBackground(parallaxBackground) Robot robot new Robot() add Player final AnimatedSprite animatedRobotSprite new AnimatedSprite(robot.centerX, robot.centerY, 122, 126, (ITiledTextureRegion) robotTextureRegion, getVertexBufferObjectManager()) scene.attachChild(animatedRobotSprite) animatedRobotSprite.animate(new long 1250,50,50 ) add right arrow button Sprite rightArrowSprite new Sprite(0, CAMERA HEIGHT 70, rightArrowTextureRegion, getVertexBufferObjectManager()) Override public boolean onAreaTouched(TouchEvent pSceneTouchEvent,float pTouchAreaLocalX, float pTouchAreaLocalY) switch (pSceneTouchEvent.getAction()) case TouchEvent.ACTION DOWN moveRight true parallaxBackground.setParallaxValue(5) break case TouchEvent.ACTION MOVE moveRight true break case TouchEvent.ACTION UP moveRight false break default break return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY) scene.attachChild(rightArrowSprite) scene.registerTouchArea(rightArrowSprite) scene.setTouchAreaBindingOnActionDownEnabled(true) scene.setTouchAreaBindingOnActionMoveEnabled(true) scene.registerUpdateHandler(new IUpdateHandler() Override public void reset() Override public void onUpdate(float pSecondsElapsed) if ( moveRight ) animatedRobotSprite.setPosition(animatedRobotSprite.getX() speedX, animatedRobotSprite.getY()) ) return scene


Creating trading card board layout in libgdx I wanna make a trading card game using libgdx. I have a general idea about how to implement the server side of the game and the game rules, but I don't know how to design the visual interface of the game (in the client side). I want to create a layout similar to the one in the image below, but quite a bit simpler. I don't have an idea of how to do it though. I'm thinking of using scene2d and Table and have a row the opponent, one for the player and two for the creatures and then each cell is a card creature. Is that a good way or is there a better way?


What's the best way to create animations when doing Android development? I'm trying to create my first Android game and I'm currently trying to figure out (with someone that will do the drawings and another programmer) what the best way to create animation is. (Animations such as a character moving, etc.) At first, the designer said that she could draw objects characters and animate them with flash so she didn't have to draw every single frame of an action. The other programmer and I don't know Flash too much so I suggested extracting all the images from the Flash animation and making them appear one after the other when the animation is to start. He said that would end up taking too much resource on the CPU and I tend to agree, but I don't really see how we're supposed to make smooth animations without it being too hard on the hardware and, if possible, not have the designer draw every single frame on Adobe Illustrator. Can an experienced Android game developper help me balance this out so we can move on to other parts of the game as I have no idea what the best way to create animations is.


Populating NPC's Outside Of Loop This was my original question Populating Sprites I used the following code to spawn Enemy Sprites in my game. I have 2 types that I was using and it would display one then remove it and display the other. It did this repeatedly(Imagine someone playing with a light switch and you have what is happening with the NPCs. EnemyType1 is Off and EnemyType2 is On.).Also It does not apply the current level number meaning, it does not spawn the number of enemies for the level. The number of enemies I want to spawn is the exact number of the level. I used other types of random methods( nextBoolean(), nextInt(), nextFloat() ). I showed the code to my friend and he told me that I would need to spawn them outside of my loop, but he did not know how to. So now I am trying to see if anyone on stack could help me. What I am trying to do is this NPC's Enemies I have 2 types of NPC's that I want to use. The number of Enemies that are spawned are equal to the the current level number. I want to be able to spawn how ever many is needed for that level and have it to where which Enemy that will spawn is random, so you don't know if you will get EnemyType1 or EnemyType2 or a Mix. Ex Level 1, only 1 Enemy spawns, the type is random. Level 2, only 2 Enemies spawn, the type is random. Level 3, only 3 enemies spawn, the type is random. etc. Thanks In Advance.


Flick Gesture in Unity3D Android I'm trying to create a football game where the user will make a flick gesture in order to kick the ball. I'm quite new to developing games in unity3d, I have successfully made a moving ball, added some rotation, gravity and some basic input (the ball follows the touch coordinates). How can I achieve the flick gesture?


Android emulator with acceleration and gyroscope simulation Is there an Android emulator that is compatible with eclipse that can simulate acceleration and tilting of a mobile device?


Concerns about Google Play Games security I want to develop a Android game using LibGDX. Let's take a classic example some player can battle another one in turn based matches. The outcome of match defines the reward in some ingame currency. There will be premium currency with in app purchases, and both can be used to purchase some upgrades. I am discovering both Android and GPG at this point. GPG allows some P2P turn battles, matchmaking and cloud saves, making it looks like quite the thing I need. However, I have concerns regarding its security. The currencies needs, for obvious reasons here, to be fully secure, non corruptable by altering saves on the device. In the same way, it is my understanding that the turn based (and real time) matches are P2P, between devices. My question is, what GPGS does to enforce security on both (cloud) saves and P2P matches ? Will I need to use some backend server for this case ? And if yes, how can I authenticate a player logged in GPG on this backend server ? Thanks for any clues about that.


Should I render all of my HUD views to a single SurfaceView? I'm using a SurfaceView and canvas to implement a game HUD, title screens etc., by overlaying standard Android view widgets over my SurfaceView. This works reasonably well and maintains an acceptable frame rate, but it is a simple game with little happening on or off screen. I have handlers flinging messages around and runOnUiThreads everywhere. Quite cumbersome. Can I draw all my views to the one SurfaceView, controlled by the main game thread? Is there an advantage to this?


Poor image quality on Android through Unity Remote I have started to work on the company's latest project using Unity3D and the workflow is just awesome. The problem is when running the game on a real Android device (using Unity Remote) the image quality is very poor in comparison to how it looks in the editor (Click for a full view. Look at those sprite edges.) Is this... caused by the phone's limited graphics capabilities or have I configured the project improperly or is it Unity Remote and actually building it for Android will fix the quality? (Based on Unity Answers site, Unity Remote is the cause http answers.unity3d.com questions 408896 android image quality is poor compared to the qual.html comment 408945)


Efficient Collision detection for polygons (fleet) in an RTS I'm trying to make an RTS for android using libgdx. I would like to have collision detection to be able to detect ships inside the range of weapons and collision between my bullets and the ships. So far my strategy has been to use a PM QuadTree that I coded myself to store every segment of every polygons. A polygon being the hitbox of a ship. Every frame I clear and add all the segments back in the quadtree. Every segment has a reference to the ship it belongs to. When I add a ship, I add it recursively to the nodes of the quadtree based on the intersection with the bounds of a node. Detection collision is done by polling every polygon inside a rectangle that look into every node that fit entirely or partially inside the rectangle. My problem is that adding every ship every frame gives bad result on Android. On Desktop it is fast enough but on Android it can takes up to 100 ms just to add around 200 segments. Is there something wrong with my implementation (it shouldn't be this slow ?) or should I use another strategy for collision detection ? I thought about clearing the quadtree only every 5 frames but it would make the detection unprecise. I have measured that some simple math operation to calculate intersection takes up to 50 more times on my android and I'm not sure why. Surely my phone cpu is not 50 times slower than my laptop, is it ? It's a sufficiently fast moving RTS. Often the whole fleet is moving, thus every segment. I heard about RDC in that article. Would that be a better algorithm ? My issue is that some ships are hard to be bounded by a sphere if they're very long but not wide.


JBox2D simple example for Android? I'm starting to develop an Android game. I've already installed jBox2D but I can't find complete code to develop a simple application from scratch using this framework. Thanks in advance!


Detect android device rotation I am developing a game in android and I want to be able to use device rotation for moving. So, I am not sure what sensors should I use. I tried gyroscope, it will do, but there are not a lot of devices that supports gyroscope sensors. So, I want to use rotation around x,y,z axis not change like landscape portrait mode. What sensors would be the best? I already tried to google it but I couldn't find anything.


How to change from 60FPS to 30FPS while keeping things smooth? Here is my current game loop final int ticksPerSecond 60 final int skipTicks (1000 ticksPerSecond) float dt 1f ticksPerSecond while(System.currentTimeMillis() gt nextGameTick amp amp loops lt maxFrameskip) updateLogic() nextGameTick skipTicks timeCorrection (1000d ticksPerSecond) 1 nextGameTick timeCorrection timeCorrection 1 loops On most devices I've tested my game on (this is an Android game BTW) it runs quite nice. As you can see, I'm using a fixed time step (defined as my ticks per second). If I reduce my Ticks Per Second to 30, everything runs at the same speed but is nowhere near as smooth. I keep hearing people say that 30fps should be OK for mobile games and everything should run great at 30 fps, but that's just not my experience. Would be grateful if someone could give me some pointers on how to achieve this.


LibGDX Google Play Game Service (Dec 2016) Cannot call Games class I'm trying to include Google Play Game Services in my Android game and I tried adding BaseGameUtils library. But it is not really working. I can call the GameHelper class from AndroidLauncher but not the Games class for getting leaderboards. I also have this warning in my console (which does not interfere with the actual problem see the answer) project ' android' Unable to resolve additional project configuration. Details groovy.lang.MissingPropertyException Could not find property 'main' on SourceSet container. Can somebody give any insight to this problem? This is my android gradle http pastebin.com ya85gGs4 And this my BaseGameUtils gradle http pastebin.com 0iyz2j12 Also the root gradle http pastebin.com in2MmYMM When I check Project Structure Problems, I have these messages EDIT I have tried changing android support library, appcompat and google play services to different versions including the latest ones but this error keeps pissing me off. PS Please feel free to edit the title. I put the date because I wanted to imply that this is a recent issue.


Android 2D terrain scrolling I want to make infinite 2D terrain based on my algorithm.Then I want to move it along Y axis (to the left) This is how I did it public class Terrain Queue lt Integer gt bottom Paint paint Bitmap texture Point screen int numberOfColumns 100 int columnWidth 20 public Terrain(int screenWidth, int screenHeight, Bitmap texture) bottom new LinkedList lt Integer gt () screen new Point(screenWidth, screenHeight) numberOfColumns screenWidth 6 columnWidth screenWidth numberOfColumns for(int i 0 i lt numberOfColumns i ) Generate terrain point and put it into bottom queue paint new Paint() paint.setStyle(Paint.Style.FILL) paint.setShader(new BitmapShader(texture, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)) public void update() bottom.remove() Algorithm calculates next point bottom.add(nextPoint) public void draw(Canvas canvas) Iterator lt Integer gt i bottom.iterator() int counter 0 Path path new Path() path.moveTo(0, screen.y) while (i.hasNext()) path.lineTo(counter, screen.y i.next()) counter columnWidth path.lineTo( screen.x, screen.y) path.lineTo(0, screen.y) canvas.drawPath(path2, paint) The problem is that the game is too 'fast', so I tried with pausing thread with Thread.sleep(50) in run() method of my game thread but then it looks too torn. Well, is there any way to slow down drawing of my terrain ?


Google Analytics collect and visualize custom data I was wondering if Google Analytics (GA) can be used to collect custom metadata about app usage and performance. An example would be to measure and collect the average frame rate (fps) of the app on the device. How can this data be presented into the Google Analytics Report? If possible, please make an example by sample source code.


Sprite animation in openGL Some frames are being skipped Earlier, I was facing problems on implementing sprite animation in openGL ES. Now its being sorted up. But the problem that i am facing now is that some of my frames are being skipped when a bullet(a circle) strikes on it. What I need A sprite animation should stop at the last frame without skipping any frame. What I did Collision Detection function and working properly. PS Everything is working fine but i want to implement the animation in OPENGL ONLY. Canvas won't work in my case. EDIT My sprite sheet. Consider the animation from Left to right and then from top to bottom Here is an image for a better understanding. My spritesheet ... class FragileSquare FloatBuffer fVertexBuffer, mTextureBuffer ByteBuffer mColorBuff ByteBuffer mIndexBuff int textures new int 1 public boolean beingHitFromBall false int numberSprites 20 int columnInt 4 number of columns as int float columnFloat 4.0f number of columns as float float rowFloat 5.0f int oldIdx public FragileSquare() TODO Auto generated constructor stub float vertices 1.0f,1.0f, byte index 0 1.0f, 1.0f, byte index 1 byte index 2 1.0f, 1.0f, 1.0f, 1.0f byte index 3 float textureCoord 0.0f,0.0f, 0.25f,0.0f, 0.0f,0.20f, 0.25f,0.20f byte indices 0, 1, 2, 1, 2, 3 ByteBuffer byteBuffer ByteBuffer.allocateDirect(4 2 4) 4 vertices, 2 co ordinates(x,y) 4 for converting in float byteBuffer.order(ByteOrder.nativeOrder()) fVertexBuffer byteBuffer.asFloatBuffer() fVertexBuffer.put(vertices) fVertexBuffer.position(0) ByteBuffer byteBuffer2 ByteBuffer.allocateDirect(textureCoord.length 4) byteBuffer2.order(ByteOrder.nativeOrder()) mTextureBuffer byteBuffer2.asFloatBuffer() mTextureBuffer.put(textureCoord) mTextureBuffer.position(0) public void draw(GL10 gl) gl.glFrontFace(GL11.GL CW) gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glVertexPointer(1,GL10.GL FLOAT, 0, fVertexBuffer) gl.glEnable(GL10.GL TEXTURE 2D) if(MyRender.flag2 1) Collision has taken place int idx oldIdx (numberSprites 1) ? (numberSprites 1) (int)((System.currentTimeMillis() (200 numberSprites)) 200) gl.glMatrixMode(GL10.GL TEXTURE) gl.glTranslatef((idx columnInt) columnFloat, (idx columnInt) rowFloat, 0) gl.glMatrixMode(GL10.GL MODELVIEW) oldIdx idx gl.glEnable(GL10.GL BLEND) gl.glBlendFunc(GL10.GL SRC ALPHA, GL10.GL ONE MINUS SRC ALPHA) gl.glBindTexture(GL10.GL TEXTURE 2D, textures 0 ) 4 gl.glTexCoordPointer(2, GL10.GL FLOAT,0, mTextureBuffer) 5 gl.glEnableClientState(GL10.GL TEXTURE COORD ARRAY) gl.glDrawArrays(GL10.GL TRIANGLE STRIP, 0, 4) 7 gl.glFrontFace(GL11.GL CCW) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glDisableClientState(GL10.GL TEXTURE COORD ARRAY) gl.glMatrixMode(GL10.GL TEXTURE) gl.glLoadIdentity() gl.glMatrixMode(GL10.GL MODELVIEW) public void loadFragileTexture(GL10 gl, Context context, int resource) Bitmap bitmap BitmapFactory.decodeResource(context.getResources(), resource) gl.glGenTextures(1, textures, 0) gl.glBindTexture(GL10.GL TEXTURE 2D, textures 0 ) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE MIN FILTER, GL10.GL LINEAR) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE MAG FILTER, GL10.GL LINEAR) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE WRAP S, GL10.GL REPEAT) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE WRAP T, GL10.GL REPEAT) GLUtils.texImage2D(GL10.GL TEXTURE 2D, 0, bitmap, 0) bitmap.recycle()


2D game physics, doing it right I have a ball that you can make jump, I have a sneaking suspicion I'm doing this wrong. It works now, to the extend that gravity pulls the object down toward the ground, but I'm having trouble manipulating the speed of the object. What this is, is a ball jumping and falling towards the ground. I have another function called "jump" that just adds a value to it's yVel I can increase gravity, and it falls faster. I can increase the jSpeed speed, and it'll rise up longer, but not faster But I can't get it to do everything faster. It just looks painfully slow, which may or may not be because of my emulator running at 11 fps, on average. Is it just my emulator, or is it something on my end? float time elapsedTime 1000F if (speed lt maxSpeed) speed speed accel if(mY mVelY lt Panel.mHeight) 0,0 is top left mVelY (speed) if (!(mY height gt Panel.mHeight)) mVelY mVelY gravity mX (float) (mX (mVelX time)) mY (float) (mY (mVelY time))


Touch point on the near plane I have a matrix created with either orthoM or frustumM GL function, where the near plane is logically the surface of the tablet. I would like to translate touch locations to their location on the near plane (that is, from device coordinates to the world coordinates). I assume this is a common enough activity so I'm wondering if a standard API function exists (or simple sequence) which can provide me with this data?


Handling different screen densities in Android Devices? Well, i know there are plenty of different sized screens in devices that run Android. The SDK I code with deploys to all major desktop platforms and android. I am aware i must have special cares to handle the different screen sizes and densities, but i just had an idea that would work in theory, and my question is exactly about that method, How could it FAIL ? So, what I do is to have an ortho camera of the same size for all devices, with possible tweaks, but anyway that would grant the proper positioning of all elements in all devices, right? We can assume everything is drawn in OpenGLES and input handling is converted to the proper camera coordinates. If you need me to improve the question, please tell me.


Slowdown in sliding background with Libgdx I m new with libgx and i have a basic question. I want an background like an image that repeats indefinetely, and moves down. I did with 2 images and it worked, but the problem is that is very slow. I stored the images with 512x512px. My code is very simple but i dont know what im doing wrong. public void render() Gdx.gl.glClearColor(0, 0, 0.2f, 1) Gdx.gl.glClear(GL20.GL COLOR BUFFER BIT) offset 600 Gdx.graphics.getDeltaTime() offset offset 512 camera.update() batch.setProjectionMatrix(camera.combined) batch.begin() batch.draw(backgroundImage, 0, offset) batch.draw(backgroundImage, 0, offset 512) batch.draw(bucketImage, 0, offset 1024) batch.end() Any suggestions will be appreciated Thanks a lot!


What screen resolution do I make an android game in? Is it safe to assume that most mobile phones and tablets today have moved to 1280x720 resolution and above and make the games in that resolution, scale down for smaller screens or is a smaller resolution like the often used 800x480 still the recommended way to do it and scale it up for larger devices?


Algorithm to zoom a plotted function I'm making a game in android and I need plot a function, my algorithm is this Override protected void onDraw(Canvas canvas) float e 0.5f from x axis to x evaluate f(x) for (float x z(canvas.getWidth()) x lt z(canvas.getWidth()) x e) float x1,y1 x1 x y1 f(x) canvas.drawPoint((canvas.getWidth() 2) x1, (canvas.getHeight() 2) y1, paintWhite) super.onDraw(canvas) This is how it works. If my function is, for example f(x) x 2, then z(x) is sqrt(x). I evaluate each point between z(x) to z(x) and then I draw them. As you can see I use the half of the size of the screen to put the function in the middle of the screen. The problem isn't that the code isn't working, actually plots the function. But if the screen is of 320 480 then this function will be really tiny like in the image below. My question is how can I change this algorithm to scale the function?. BTW what I'm really wanting to do is trace a route to later display an animated sprite, so actually scale this image doesnt gonna help me. I need change the algorithm in order to draw the same interval but in a larger space. Any tip helps, thanks! Current working result Desired result UPDATE I will try explain more in detail what the problem is. Given this interval 15...15 ( z(x) to z(x)) I need divide this points in a bigger interval 320...320 ( x to x). For example, when you use some plotting software like this one. Although the div where is contain the function has 640 px of width, you dont see that the interval is from 320 to 320, you see that the interval is from 6 to 6. How can I achieve this?


How could I access game data from a dev machine at runtime from a mobile platform? When working on a game on a mobile platform, having read write access to game data (assets, configuration files) stored on the dev machine at runtime would enable building of tools to quickly iterate, debug, and analyze the game at runtime. For iOS amp Android, is there any way to have access to these data files from the dev machine while the game is running on the mobile device? Please do not recommend a tool, or a 3rd party engine that does this.


Android AndEngine creating a body behind the sprite exactly I am using AndEngine for Android. I created a body, but it is not behind the sprite as I wanted. Body.setTransform(Sprite.getX() 32, Sprite.getY() 32, 0) This is what I am currently using and this is how it appears. My body is the white circular borders, and my sprite is the red circle. and When I remove 32 from the code the body doesn't even appear. Extra code FIXTURE DEF PhysicsFactory.createFixtureDef( 1, density 0.75f, elasticity 0.5f, friction false) isSensor the Body Body PhysicsFactory.createCircleBody(this.physicsWorld, Sprite, BodyType.KinematicBody, this.FIXTURE DEF) Body.setUserData("eSprite") this.physicsWorld.registerPhysicsConnector(new PhysicsConnector(Sprite, Body, true, true) my sprite is 65px ..


Getting body position I am using BodyA.getPosition().x and BodyA.getPosition().y to get the x and y vector of a body location so i may attach some text above its head, but the log of that position prints out something like 3.666757..... I want this text to be moving when the body moves so it should be relative to the body position at all times until removed. Currently when I try to use this speech new TickerText( 0, 0, font, ptext, new TickerText.TickerTextOptions( 10 ), ResourceManager.getInstance().vertexManager ) speech.setBlendFunction( GLES20.GL SRC ALPHA, GLES20.GL ONE MINUS SRC ALPHA ) speech.setScale( 0.5f ) speech.setAutoWrapWidth( 500f ) speech.setAutoWrap( AutoWrap.WORDS ) speech.setPosition( xVal, yVal ) The text is not displayed on screen on screen at all, I figure its the x and y location being wrong because when I manually set x and y to positions I know would be on the screen area it is shown. I am looking for help as how to get the actual X and Y coordinate of the body on screen so I can have the text follow the body.


How to decide how much to charge for development? So two other friends and I are a very small game dev studio. So far we haven't released a game but we have 2 games almost ready to launch. A bigger studio saw our work and now they want to work with us they need people to develop mobile games for them (iOS, Android). They want us to set the price for the projects (can't tell the specifics we signed a NDA). They will give us all the assets (graphics sound) so we only have to code. And because they only work with Unity3D we have to learn it. How do we decide how much to charge for the projects?


Is deferred rendering shading possible with OpenGL ES 2.0 ? I asked this on StackOverflow, but it might make more sense here Has anyone implemented deferred rendering shading under OpenGL ES 2.0? It doesn't support MRTs, so with only one color buffer, it's not something that can be implemented in the "usual" manner. Specifically, I'm exploring on iPad, iPhone4 (maaaybe iPhone 3gs), and Android. On the GLESView app on iPad iPhone4 iPhone3gs, the GL OES RGB8 RGBA8 extension is present, and I haven't looked too deeply yet, but with 8bits channel, this idea is interesting http www.gamedev.net topic 562138 opengl es 20 and deferred shading Any other ideas? Is it even worth doing, performance wise?


How do I access a Unity class from an Android Activity? I have made my own C classes in Unity. How can I access them from the Android Activity that starts the UnityPlayer? Example I have a C class called testClass in Unity class testClass public static string myString "test string" From the Android activity in Java, I want to access a member of that class string str testClass.myString Is this possible? If so, how? Is there another way to do this? In the end, I basically want to communicate between my Android activity and the UnityPlayer object. Edit I found a solution. I looked at building Android plugins for Unity but this wasn't satisfactory to me. I ended up building a socket client server interface in Unity with C and another one in Java for the Android app Unity listens on port X and broadcasts on port Y. The Android activity listens on port Y and broadcasts on port X. This is necessary as both interfaces are running on the same host. So that's how I solved my problem, but I'm open for any suggestions if anyone knows a better way of communicating between the Unityplayer and your app.


Do Google Apple provide the multiplayer servers for an app themselves? I have an app that I have been working on and I was wondering does Google Apple host the server requirements for the multiplayer aspects of an app?


Drawing Text on a scene I am not sure if I am missing something but I was thinking about how text entities are drawn on a scene, are they drawn with an offset depending on the length of the text? I notice that when I add a new Text element at say new Text(10, 20,..... and the actual text content is 50 words long the text is drawn far over to the right and when I use the same instance with a smaller text content that text is drawn closer to the actual coordinates I need. Should I always recalculate X and Y vectors with respect to the current portion of the scene being shown on the camera? Words String words "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here. " "Hello, I see that your new here." method call createSpeech( BodyA.getPosition().x, BodyA.getPosition().y, words ) method definition private void createSpeech(float xVal, float yVal, String ptext) xVal xVal GameConstants.PIXEL TO METER RATIO DEFAULT yVal yVal GameConstants.PIXEL TO METER RATIO DEFAULT speech new TickerText( 0, 0, ResourceManager.getInstance().font, words, new TickerText.TickerTextOptions( 10 ), ResourceManager.getInstance().vertexManager ) speech.registerEntityModifier( new AlphaModifier( 5, 0.0f, 1.0f ) ) speech.setBlendFunction( GLES20.GL SRC ALPHA, GLES20.GL ONE MINUS SRC ALPHA ) speech.setScale( 0.5f ) speech.setHorizontalAlign( HorizontalAlign.CENTER ) speech.setAutoWrapWidth( 500f ) speech.setAutoWrap( AutoWrap.WORDS ) speech.setPosition( xVal, yVal ) Screenshots The Red and orange lines indicate where the text is shown currently, the blue region is where I want the text to be shown. The calculations I used to set the text position and the text itself is shown above I think the text object itself might have something to do with the offset positioning because when i use a smaller string value the position of the text changes as well


Stencil Buffer not working as expected in OpenGL ES 2.0 (Android) I'm trying to get to grips with the stencil buffer. Apart from setting up viewport, camera, etc, my OpenGL ES 2.0 initialisation code is GLES20.glDisable(GLES20.GL CULL FACE) GLES20.glDisable(GLES20.GL DEPTH TEST) GLES20.glEnable(GLES20.GL BLEND) GLES20.glEnable(GLES20.GL STENCIL TEST) GLES20.glBlendFunc(GLES20.GL SRC ALPHA, GLES20.GL ONE MINUS SRC ALPHA) GLES20.glClearColor(0.2f, 0.8f, 1.0f, 0) GLES20.glClearStencil(0) My main code is below. GLES20.glEnable(GLES20.GL STENCIL TEST) GLES20.glColorMask(false, false, false, false) GLES20.glStencilFunc(GLES20.GL NEVER, 1, 0xFF) GLES20.glStencilOp(GLES20.GL REPLACE, GLES20.GL KEEP, GLES20.GL KEEP) GLES20.glStencilMask(0xFF) GLES20.glClear(GLES20.GL STENCIL BUFFER BIT) draw sprites player.draw() GLES20.glColorMask(true, true, true, true) GLES20.glDepthMask(true) GLES20.glStencilMask(0x00) don't effect the stencil buffer GLES20.glStencilFunc(GLES20.GL EQUAL, 0, 0xFF) draw where stencils value is 0 if we want... GLES20.glStencilFunc(GLES20.GL EQUAL, 1, 0xFF) draw where stencils value is 1 if we want... level.draw() GLES20.glDisable(GLES20.GL STENCIL TEST) However, this doesn't work. As expected this code does not draw the payer. The player (or the filled square surrounding the player) should be drawn to the stencil buffer. The next part of the code should draw the level, which should be clipped to the boundary of the player (or the square boundary of the player). What this code actually does is draw the whole level. Why is the code not clipping the level to the profile of the player, or at least the square bounding the player ?


How to get faster iteration times in android development I'm creating a game on the android platform that uses the resources raw folder for assets and scripts. The problem is that every time I change something I have to rebuild the application to test the new variant. Of course this is bad for iteration times. Any ideas about what I can do to avoid rebuilding every time I change something? This .apk format is getting on my nerves now that I have to recreate it every time I change a word in my scripts. Or at least how to make eclipse auto rebuild every time I change something in my resources folder so that I don't have to go to Project Build every time?


What is Google Play Services Multiplayer? This question might be off topic, i don't know where should i ask it. What's the difference between Google Play Real Time Multiplayer, Google Play Turn Based Multiplayer and sockets?


Is there any "object" in monogame for windows phone 8, that is similar to Toast in Android? The title pretty much sums it all. Is there any "object" in monogame for windows phone 8 (for monogame to be exact), that is similar to Toast in Android? My purpose is to give a notification hint at what user do, until certain period until next user input. For example If the player tapped "attack", then there is text shown "Select your target" in either top or bottom screen. Just like Toast in android. Note 1 I can do it manually, but i'm just curious. If I can use a pre made function (such as Toast) it'll be simpler to implement, rather than making it myself. Note 2 Mine is a turn based tactic game (such as FF Tactic) Thank you.


Desaturate texture using mask in OpenGL 2 I have a very large texture i am using as background and i want to apply a filter to a small part of it, the "small part" is defined by the alpha layer of another texture i have (which is still RGB8888), i am not sure what's the best approach to do this. I'd like to keep the same (very simple) shader i am already using for other sprites, which is similar to the basic one, i.e. precision mediump float uniform sampler2D uTexture varying vec2 vTexPos void main() gl FragColor texture2D(uTexture, vTexPos) So, i have some questions How can i apply my filter only to "masked" region and avoid drawing others? Do i have any performance loss if i draw the big texture again once loaded to just apply it to a small portion of the screen? Can i map a second texture to the shader and use something like "if uTexture2 ! null" apply as mask? Will this give me any performance gain compared to using a second shader? Both textures are premultiplied, how should i handle alpha masking? What id like to do is something like this (original, mask, result) My environment is Android 4.0, im using GLES20.


Progress bar in Super Hexagon using OpenGL ES 2 (Android) I'm wondering how the progress bar in Super Hexagon was made. (see image, top left) Actually I am not very sure how to implement a progress bar at all using OpenGL ES 2 on Android, but I am asking specifically about the one used in Super Hexagon because it seems to me less straightforward obvious than others the bar changes its colour during game play. I think one possibility is to use the built in Android progress bar. I can see from some Stackoverflow questions that you can change the default blue colour to whatever you want, but I'm not sure whether you can update it during the game play. The other possibility I can think of for implementing a progress bar is to have a small texture that starts with a scale of 0 and that you keep scaling until it reaches the maximum size, representing 100 . But this suffers from the same problem as before you'll not be able to update the colour of the texture during run time. It's fixed. So what's the best way to approach this problem? I'm assuming he didn't use a particular library, although if he did, it would be interesting to know. I'm interested in a pure OpenGL ES 2 Android solution.


AndEngine edit elasticity on action I'm making a game for Android with AndEngine. It's going quite well, but now I'm stuck on something. My main character has a elasticity set in its fixturedef so it bounces around throughout the game. Now i want the user to be able to not let the player bounce when he does a control. So my question how can I modify the elasticity of my character? Because I saw you can adjust the setDensity and setFriction, but I cant see the setElasticity.... Thanks in advance!


Android Studio with libGDX doesn't recognize boolean In my game, when the users clicks an image button, the value of a boolean changes and then the game is closed. I mean, if I want to restart the game, I click this image button, the game is closed and immediately is opened. However this doesn't happen because the value of the boolean is false and I don't know why at all. Here is the code of the image button playagain.addListener(new ClickListener() Override public void clicked(InputEvent event, float x, float y) interfaccia.rigioca() Gdx.app.exit() ) And this is the code of the MainActivity public class MainActivity extends Activity implements MyGdxGame.GestioneClick, Serializable MainActivity activity boolean start Override public void onCreate(final Bundle bundle) super.onCreate(bundle) setContentView(R.layout.layout) activity this findViewById(R.id.button).setOnClickListener(new View.OnClickListener() Override public void onClick(View v) startActivity() ) Override public void onResume() super.onResume() if(start) startActivity() Override public void menu() start false Override public void rigioca() start true public void startActivity() Intent intent new Intent(MainActivity.this,AndroidLauncher.class) intent.putExtra("MainActivity",activity) activity.startActivity(intent) As you can see, rigioca method is called and start sould be true. I checked ALL with logs and we can say that the value is true. Then resume method is called but start value is false! How is it possible? I also took away start false in menu method, but that isn't the problem. Why is this variable false!? Note onDestroy and onCreate aren't called but the activity is destroyed.