_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
7 | 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() |
7 | 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? |
7 | 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. |
7 | 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 |
7 | 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. |
7 | 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? |
7 | 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. |
7 | 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 |
7 | 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 |
7 | 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 |
7 | 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? |
7 | 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() |
7 | 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? |
7 | 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 ... |
7 | 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. |
7 | 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. |
7 | 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() |
7 | 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 |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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! |
7 | 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? |
7 | 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 |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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) |
7 | 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 |
7 | 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? |
7 | 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). |
7 | 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"? |
7 | 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? |
7 | 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? |
7 | 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? |
7 | 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? |
7 | 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? |
7 | 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? |
7 | 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 ? |
7 | 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? |
7 | 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? |
7 | 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? |
7 | 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. |
7 | 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) |
7 | 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 |
7 | 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 |
7 | 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! |
7 | 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. |
7 | 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 |
7 | 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. |
7 | 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 |
7 | 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 |
7 | 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? |
7 | 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. |
7 | 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. |
7 | 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? |
7 | 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? |
7 | 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. |
7 | 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? |
7 | 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) |
7 | 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. |
7 | 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! |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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 ? |
7 | 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. |
7 | 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() |
7 | 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)) |
7 | 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? |
7 | 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. |
7 | 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! |
7 | 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? |
7 | 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? |
7 | 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. |
7 | 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 .. |
7 | 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. |
7 | 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? |
7 | 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? |
7 | 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. |
7 | 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? |
7 | 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 |
7 | 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 ? |
7 | 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? |
7 | 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? |
7 | 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. |
7 | 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. |
7 | 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. |
7 | 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! |
7 | 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. |
7 | Counting multiple touches using Cocos2dx 3.2 I'm trying to count the number of active touches in screen in order to perform an an action in case that there are two touches auto jumpListener EventListenerTouchAllAtOnce create() jumpListener gt onTouchesBegan (const std vector lt Touch gt amp touches, Event event) CCLOG("Multi touch detected d", touches.size()) if(touches.size() 2) this gt player gt jump() But even if I'm touching with two fingers, I get that only 1 touch has been made, any suggestions? |
7 | Android Swipe In Unity 3D World with AR I am working on an AR application using Unity3D and the Vuforia SDK for Android. The way the application works is a when the designated image(a frame marker in our case) is recognized by the camera, a 3D island is rendered at that spot. Currently I am able to detect when which objects are touched on the model by raycasting. I also am able to successfully detect a swipe using this code if (Input.touchCount gt 0) Touch touch Input.touches 0 switch (touch.phase) case TouchPhase.Began couldBeSwipe true startPos touch.position startTime Time.time break case TouchPhase.Moved if (Mathf.Abs(touch.position.y startPos.y) gt comfortZoneY) couldBeSwipe false track points here for raycast if it is swipe break case TouchPhase.Stationary couldBeSwipe false break case TouchPhase.Ended float swipeTime Time.time startTime float swipeDist (touch.position startPos).magnitude if (couldBeSwipe amp amp (swipeTime lt maxSwipeTime) amp amp (swipeDist gt minSwipeDist)) It's a swiiiiiiiiiiiipe! float swipeDirection Mathf.Sign(touch.position.y startPos.y) Do something here in reaction to the swipe. swipeCounter.IncrementCounter() break touchInfo.SetTouchInfo (Time.time startTime,(touch.position startPos).magnitude,Mathf.Abs (touch.position.y startPos.y)) Thanks to andeeeee for the logic. But I want to have some interaction in the 3D world based on the swipe on the screen. I.E. If the user swipes over unoccluded enemies, they die. My first thought was to track all the points in the moved TouchPhase, and then if it is a swipe raycast into all those points and kill any enemy that is hit. Is there a better way to do this? What is the best approach? Thanks for the help! |
7 | how to do sprinkle effect of water in opengl in android? I want to achieve sprinkling effect of water in android using opengl. so, do i need to achieve it with graphics? is there any other way to do it using opengl? or how can i start working on this,any links? |
7 | Box 2d Level Editor for AndEngine I am getting started with Box2d in AndEngine. I need to know if there is any level editor to be used with box2d and gives output capatable with AndEngine. Is there any tool which can help me building complex body with joints like a bike or car? What do you suggest which is the best way to do this kind of stuff. |
7 | What should I keep in mind when making 2D games for multiple resolutions? I'm making a 2D (Android) game. Android devices vary quite a lot in screen resolution what do I need to keep in mind when making my game? Do I need to keep big versions of all images and scale down depending on the resolution (doesn't that waste space)? Do bitmap fonts scale well or do I need to use something else? Anything else I'm forgetting? |
7 | Reducing APK File Size by using JPG instead of PNG for game background images I've just finished my (openGL ES 2.0 Android) game and it's almost ready for Alpha testing. When I export the application to an APK File, the file is taking up 16MB and I would like to reduce this as much as I can. Here are some points about what the project contains and what I've tried to reduce the size already 222kb of Ogg Vorbis files used for Sound Effects 1 x MP3 file at 5.59MB (128kbps Bitrate) 4 x sets of PNG files used for textures (XHDPI, HDPI, MDPI amp LDPI I'm not using XXHDPI) Just over 1MB of code What I've tried thus far to get where I am I've optimised the PNG files using Optiping I've applied ProGuard to my code before exporting, this didn't really help by much as 99 of my app is resources. So my question is, is there really much else I can do to reduce the size of the APK? I was thinking about maybe using JPG format source files for my Background OpenGL textures instead of PNG anyone have any experience with this? Does it hurt performance at all? I can see that it would make quite a difference my atlas of backgrounds in PNG format for XHDPI is 1.7MB and a 90 compressed JPG comes in at around 650KB. I'm just not sure if it's a good idea as everyone always advocates PNG JPG. Any pointers from personal experience would be helpful amp also if I've overlooked anything other than using JPG's. |
7 | Extrapolation breaks collision detection Before applying extrapolation to my sprite's movement, my collision worked perfectly. However, after applying extrapolation to my sprite's movement (to smooth things out), the collision no longer works. This is how things worked before extrapolation However, after I implement my extrapolation, the collision routine breaks. I am assuming this is because it is acting upon the new coordinate that has been produced by the extrapolation routine (which is situated in my render call ). After I apply my extrapolation How to correct this behaviour? I've tried puting an extra collision check just after extrapolation this does seem to clear up a lot of the problems but I've ruled this out because putting logic into my rendering is out of the question. I've also tried making a copy of the spritesX position, extrapolating that and drawing using that rather than the original, thus leaving the original intact for the logic to pick up on this seems a better option, but it still produces some weird effects when colliding with walls. I'm pretty sure this also isn't the correct way to deal with this. I've found a couple of similar questions on here but the answers haven't helped me. This is my extrapolation code public void onDrawFrame(GL10 gl) Set Re set loop back to 0 to start counting again loops 0 while(System.currentTimeMillis() gt nextGameTick amp amp loops lt maxFrameskip) SceneManager.getInstance().getCurrentScene().updateLogic() nextGameTick skipTicks timeCorrection (1000d ticksPerSecond) 1 nextGameTick timeCorrection timeCorrection 1 loops tics extrapolation (float)(System.currentTimeMillis() skipTicks nextGameTick) (float)skipTicks render(extrapolation) Applying extrapolation render(float extrapolation) This example shows extrapolation for X axis only. Y position (spriteScreenY is assumed to be valid) extrapolatedPosX spriteGridX (SpriteXVelocity dt) extrapolation spriteScreenPosX extrapolationPosX screenWidth drawSprite(spriteScreenX, spriteScreenY) Edit As I mentioned above, I have tried making a copy of the sprite's coordinates specifically to draw with.... this has it's own problems. Firstly, regardless of the copying, when the sprite is moving, it's super smooth, when it stops, it's wobbling slightly left right as it's still extrapolating it's position based on the time. Is this normal behavior and can we 'turn it off' when the sprite stops? I've tried having flags for left right and only extrapolating if either of these is enabled. I've also tried copying the last and current positions to see if there is any difference. However, as far as collision goes, these don't help. If the user is pressing say, the right button and the sprite is moving right, when it hits a wall, if the user continues to hold the right button down, the sprite will keep animating to the right, while being stopped by the wall (therefore not actually moving), however because the right flag is still set and also because the collision routine is constantly moving the sprite out of the wall, it still appear to the code (not the player) that the sprite is still moving, and therefore extrapolation continues. So what the player would see, is the sprite 'static' (yes, it's animating, but it's not actually moving across the screen), and every now and then it shakes violently as the extrapolation attempts to do it's thing....... Hope this help |
7 | Specific Physics Lessons and Reference for Game Development What "Physics stuffs" should I learn in game developments? I'm reading about Verlet Integration, and I'm wondering what other lesson should I learn and if there are available resources can you please provide some link or anything. Thanks. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.