_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
7 | Is libgdx fit for 2D game development on Android or are there simpler alternatives? I'm looking for a Java framework to develop 2D games on desktop and Android. I've looked at Slick and I really like the API, however the developer himself says if you want a framework for Android and desktop best go with libgdx atm. Now I'm reading up on libgdx, but I'm wondering if there are simpler alternatives for just doing 2D sprite stuff on Android and desktop. I'm only interested in creating NES like graphics, nothing too fancy. Something like this. Because on the wiki of libgdx it says you can't use the OrtographicCamera with OpenGL ES 2.0 (http code.google.com p libgdx wiki OrthographicCamera), but I read (http www.badlogicgames.com wordpress ?p 504) when your device supports OpenGL ES 2.0 it doesn't support 1.0, so you can't effectively use OrtographicCamera on OpenGL ES 2.0 devices? I'm confused, should I go with libgdx? Are there simpler alternatives? |
7 | Unity3D Android pause screen double click issue I made a pause script for the game im developing for android. I added the script to the GUITexture I created and placed on the top right side of the screen.The issue stands at the part where if the player clicks the pause button then clicks resume then he wants to pause the game again.When he clicks pause the second time the buttons dont show up unless he clicks again. This is the script pragma strict var paused false var isButtonVisible boolean true function OnMouseDown() this.paused !this.paused Time.timeScale 0 isButtonVisible true function OnGUI() if ( isButtonVisible ) if(this.paused) if (GUI.Button(Rect(Screen.width 2 100,Screen.height 2 3,200,50),"Restart")) Application.LoadLevel(Application.loadedLevel) Time.timeScale 1 isButtonVisible false if (GUI.Button(Rect(Screen.width 2 100,Screen.height 2 50,200,50),"Resume")) Time.timeScale 1 isButtonVisible false Insert the rest of the pause menu logic if (GUI.Button(Rect(Screen.width 2 100,Screen.height 2 56,200,50),"Main Menu")) Application.LoadLevel ("MainMenu") isButtonVisible false Time.timeScale 1 Thank you. |
7 | 'Resetting' Google Play Games Services so app forgets it previously connected (so it shows confirmation screen again) When I first integrated Google Play Games Services into my app, it came up with a 'confirmation screen', something like App Name wants to connect to Google Play Game Services I don't recall the exact wording. While Alpha testing my app, one of my users has discovered a potential issue where he presses 'cancel' at that point instead of connecting. I would like to try to resolve this issue, but I can't recreate it because I can't work out how I can get that confirmation screen again! I have implemented a 'log out' button in my app and that works, but when subsequently connecting, it just goes ahead without displaying the confirmation screen again. Any ideas how I can force that screen to show again for testing?! |
7 | OpenGL ES, object intersection artifacts I was developing a C implementation of OpenGL for Android and I noticed those weird artifacts that formed between 2 intersecting objects (or triangles) Here are the artifacts on Android The weird thing is that exactly the same library, running on my windows machine, with exactly the same shaders is not giving the same results (sorry for the bad image resolution) No artifacts on windows I know about the existence of Z fighting, but wouldn't that issue persist on Windows as well? I am using a 16 bit depth buffer resolution on Android (which seems to be the maximum here). Is there something I could be missing or doing wrong? Thank you! |
7 | Efficiently detecting objects inside multiple radius I would like to create a game for mobile that require to calculate multiple time by seconds which moving objects are in the radius of moving points. The game is highly inspired from Gratuitous Space Battles, the radius being from the weapons. Thus, I would like to know if it's realist to expect to be able to know among 1000 moving objects, in which radius they are among 1000 moving points 100 times per seconds on an average android device. In term of complexity, if there is an algorithm better than O(N M), N being the number of moving objects and M the number of radius from M moving center and if an algorithm can benefit from the fact that the moving objects are near their precedent position. |
7 | GLSL Shader not compiling (Android LibGDX) and no log available I'm trying to get a "ripple" shader working for OpenGL ES 2.0 (using LibGDX). However, I can't get it to compile, and for some reason ShaderProgram.getLog() returns an empty string even though the Shader didn't compile. I am 100 confident that the vertex shader is correct.. here's the fragment shader (not written by me, but I modified it a bit long time ago.. when I had a desktop project and it worked back then) version 120 precision mediump float varying vec2 v texCoords uniform float time uniform float alpha uniform float waveLengthMultiplier uniform sampler2D u texture void main() vec2 center vec2(0.5, 0.5) vec2 tc v texCoords.xy vec2 p 1.0 2.0 (tc offset) float len length(p) waveLengthMultiplier vec2 uv tc (p len) cos(len 12.0 time 4.0) 0.03 vec3 col texture2D(u texture, uv).xyz gl FragColor vec4(col, alpha) I'm still not very well versed with shaders, as I've used them only a little.. Like I said, getLog() returns an empty string, so I'm hoping someone spots an error in the code. |
7 | Gradually reduce speed Basically I am working on following application of android version Party Games Drinking Wheel For this I want to rotate wheel and want to stop wheel at specific point. But I want this with gradually decreasing speed. For example at start I have speed of 10 then at stop time it at 0. So wheel stop smoothly. At presently I have working code but it stop suddenly. registerEntityModifier(new RotationModifier(desireTime, 359f, desireRotation, new IEntityModifierListener() Override public void onModifierStarted(IModifier lt IEntity gt pModifier, IEntity pItem) Override public void onModifierFinished( IModifier lt IEntity gt pModifier, IEntity pItem) mPointer.stopRotation() showWindowAfterSomeTime(randomSegment) , EaseLinear.getInstance())) I want some help in this. Thanks for your time. |
7 | Setting density for Android game I am developing an Android game, in which a ball (bitmap) translates( is in motion). So I have provided motion equations for the ball. I have checked my app on Samsung galaxy S2 whose actual density is roundly 252 dpi, and It works fine on that. So my question is that Does these motions of bitmaps in surfaceView, depends on actual density of phone( i.e 252 dpi for S2) or generalized density(i.e 240 dpi). I am confused whether if I run this app on 235 dpi smartphone, So will it have the same performance of motion as it is on Galaxy S2( with 252 dpi) or it would be little slow ? Any help will be appreciated. Let me elaborate it with coding. For example a linear motion of a ball is defined as with this equation x x 4 Now If I run this app, on Samsung galaxy S2(252dpi, and hdpi), So It will give me a particular speed motion, let say P is the speed of the ball. Now If I run this application on Samsung Galaxy S3(300 dpi, xhdpi), So the ball speed gonna be slow on this density, meaning less than the speed P. So I will need the same speed on xhdpi density phone. So will use these conversion formulas dx (x 160) 240 px (dx 320) 160 Hence the speed will be either exact or little different from P.(This is my confusion). That Whether the speed will be as same as it was on S2. So my Question at this point is that my app worked on Samsung Galaxy S2 with the speed p, that I desired. As S2 is of 252 dpi, So Should I Include 240(Generalized density or 252 (Actual density) in my this line of coding ? dx (x 160) 240 Thanks ! |
7 | Vectors and corners of squares I am having some problems with some vector math. Imagine a square and coming from each corner of the square is an invisible vector, which starts at the square's centre and ends at the edge of the screen. a d b c THIS IS A VERY CRUDE IMAGE AND THE ANGLES OF THE VECTORS ARE NOT EQUAL There are 4 areas a, b, c and d I would like to say that if you touch within one of the areas then something happens. Is there a simple way to do this? |
7 | How do I change my gravity and jumping logic to put the character at a specific height at a specific point in time? I'm making a 2D platformer on Android using libGDX. One thing I've had a problem with recently is gravity and jumping. I found a few tutorials on the internet and was able to come up with this... public static final int JUMP HEIGHT 64 public static final float JUMP GRAVITY 6.0f public static final float MAX GRAVITY 20.0f public static final float GRAVITY 19.0f private void updateGravity(float delta) if(Gdx.input.isTouched() amp amp !jumping) jumping true gravity Config.JUMP GRAVITY if(jumping) change frame to jump sprite.setRegion(walkFrames 0 ) sprite.translate(0, ( 1 gravity)) runner has landed? if(sprite.getY() lt idleY) jumping false sprite.setPosition(Config.RUNNER X, idleY) slowdown fall if (gravity lt Config.MAX GRAVITY) gravity Config.GRAVITY delta The code works and my character will jump and fall smoothly. Although the time it takes for him to jump and comedown is independent from delta the height he jumps is not. If the device lags while jumping he will jump only a portion of how high he should. For the life of me I cannot get it to make sure it jumps a specific height (JUMP HEIGHT) and in a specific time independent of the delta. |
7 | Raycast not working on touchscreen (Android tablet phone) I have a raycast that works in the unity editor but not when I build it for Android( tablet or phone, neither work). The code I'm using is as follows public class DirectionalTilePlacing MonoBehaviour public LayerMask levelLayer private int tileType public int Tiletype get return tileType set tileType value RaycastHit hit Vector2I placePosition Update is called once per frame void Update() Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast(ray, out hit, Mathf.Infinity, levelLayer)) if (hit.collider.tag "Replaceable") transform.position new Vector3(Mathf.Floor(hit.point.x) 0.5f, Mathf.Floor(hit.point.y), Mathf.Floor(hit.point.z) 0.5f) GetComponent lt MeshRenderer gt ().enabled true if (Input.GetMouseButtonUp(0)) ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast(ray, out hit, Mathf.Infinity, levelLayer)) if (hit.collider.tag "Replaceable") placePosition new Vector2I((int)transform.position.x, (int)transform.position.z) EditorManager.map.SetEmpty(placePosition) EditorManager.map.BrushTile(EditorManager.map.TypeToObject((Tile.tileType)tileType), placePosition, (Tile.tileType)tileType) GetComponent lt MeshRenderer gt ().enabled false gameObject.SetActive(false) Everything up until any Physics.Raycast line works. The idea is that there is a ray casted from the position your finger is at when touching the screen. |
7 | How to fit a bitmap to a random size rect so it does not strech? (Android Studio) I'm trying to fit a bitmap to a random size rect but I don't want the bitmap to be streched out. I've tried using BitmapShader and tile it but it become animated and not fixed. Here is my code without BitmapShader. public void draw(Canvas canvas) Paint paint new Paint() canvas.drawBitmap(spike1, null, rectangle, paint) canvas.drawBitmap(spike1, null, rectangle2, paint) Here is my code with BitmapShader. public void draw(Canvas canvas) Paint paint new Paint() paint.setShader(new BitmapShader(spike1, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)) canvas.drawRect(rectangle, paint) canvas.drawRect(rectangle2, paint) Here is a picture of my problems Can somebody tell what I need to do so the image is fix but not stretched? |
7 | Are frequent game updates a solution for preventing multiplayer cheating? I'm creating a game on Android where the enforcement of rules can only take place on client side (I can't shift it to server side...think aimbotting but in my case I wouldn't even be able to use heuristics to detect it!). As I've read many times, the client side is impossible to 100 protect from modification hacking. I am going to include protections such as ProGuard obfuscation. But also I'm going to use a formula in the code which encrypts data from the client. Hackers cheaters can decompile the code and locate this formula eventually. But how long will it take for them to uncover the encryption formula? A day, a week? Actually, how long in general does it take for a game to be modded for cheating? Can I release updates to my game so that by the time hackers release modded versions of my app to public, they become obsolete? If I did release updates, I wouldn't require updates for single player mode, but only when they tried to do multiplayer would a message display telling them they must update. I just really want to make multiplayer fair and not scare off players because they face opponents with uber awesome hax. |
7 | My Game Renders Awful In Android Build I'm working on a 3D Sniper game and have finished the project. When I test it on Windows (7). It's All Fine, not even a bug. But when I take the app into android (Bluestacks App Player), my buttons and images render in Solid Black color. and my trees are Solid White. Some materials are rendering black too. You can see this in the image below That Black Square On Top Right Corner Is A UI Button And The White Regions Are Tree And Bushes. The Black Thing In The Bottom Is A APC Tank. |
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 | cannot implement GLSurfaceView.RENDERMODE WHEN DIRTY I'm trying simply to display an openGL surface when I click the screen using GLSurfaceView.RENDERMODE WHEN DIRTY mode but the surface does not display when I click it , why ? my Activity public class ViewManager extends Activity private GLSurfaceView surfaceView Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState) surfaceView new GLSurfaceView(this) surfaceView.setEGLContextClientVersion(2) surfaceView.setRenderer(new MyRenderer()) surfaceView.setRenderMode(GLSurfaceView.RENDERMODE WHEN DIRTY) surfaceView.setOnTouchListener(new View.OnTouchListener() Override public boolean onTouch(View v, MotionEvent event) if(event! null) if (event.getAction() MotionEvent.ACTION DOWN) surfaceView.requestRender() return true else return false ) Override protected void onResume() super.onResume() surfaceView.onResume() Override protected void onPause() super.onPause() surfaceView.onPause() |
7 | Problem converting FBX file into XNB I create a Monogame Content Project to convert assets into XNB. For FBX file without texture there is no problem the file is correctly converted and when I load XNB into my project everything is ok. The problem occours when i have associated to fbx file a texture map in this case both FBX and PNG files are converted to XNB but when i try to load these XNB files into my project the following problem occours "ContentLoadException Could not load Models maze1 asset as a non content file!" Note maze1 is the XNB file that was converted from FBX. How can I solve this problem? Thank you in advance |
7 | Location of drawables Is it possible to get the location of a drawable in Android Studio? Example drawable.getLocationonScreen() I want to use it for collision detection. |
7 | Profiling the GPU of a tablet We are working on a tablet game in Unity Pro (for the first time). Unity's profiler works great for probing the CPU, but the tablet's GPU isn't supported in the profiler, so we have no idea where the rendering bottlenecks are. Are there any other means of profiling the GPU of an android tablet? (We are working with a Samsung galaxy tab 2 10.1 ) How do other mobile devs do this? We are basically looking for any ways of getting info from the gpu as we're running the game. Benchmarking software wouldn't help we don't need benchmark scores. Cheers! |
7 | How to remove a box2d body when collision happens? I m still new to java and android programming and I am having so much trouble Removing an object when collision happens. I looked around the web and found that I should never handle removing BOX2D bodies during collision detection (a contact listener) and I should add my objects to an arraylist and set a variable in the User Data section of the body to delete or not and handle the removing action in an update handler. So I did this First I define two ArrayLists one for the faces and one for the bodies ArrayList lt Sprite gt myFaces new ArrayList lt Sprite gt () ArrayList lt Body gt myBodies new ArrayList lt Body gt () Then when I create a face and connect that face to its body I add them to their ArrayLists like this face new AnimatedSprite(pX, pY, pWidth, pHeight, this.mBoxFaceTextureRegion) Body BoxBody PhysicsFactory.createBoxBody(mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef) mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, BoxBody, true, true)) myFaces.add(face) myBodies.add(BoxBody) now I add a contact listener and an update handler in the onloadscene like this this.mPhysicsWorld.setContactListener(new ContactListener() private AnimatedSprite face2 Override public void beginContact(final Contact pContact) Override public void endContact(final Contact pContact) Override public void preSolve(Contact contact,Manifold oldManifold) Override public void postSolve(Contact contact,ContactImpulse impulse) ) scene.registerUpdateHandler(new IUpdateHandler() Override public void reset() Override public void onUpdate(final float pSecondsElapsed) ) My plan is to detect which two bodies collided in the contact listener by checking a variable from the user data section of the body, get their numbers in the array list and finally use the update handler to remove these bodies. The questions are Am I using the arraylist correctly? How to add a variable to the User Data (the code please). I tried removing a body in this update handler but it still throws me NullPointerException , so what is the right way to add an update handler and where should I add it. Any other advices to do this would be great. Thanks in advance. |
7 | Problem converting FBX file into XNB I create a Monogame Content Project to convert assets into XNB. For FBX file without texture there is no problem the file is correctly converted and when I load XNB into my project everything is ok. The problem occours when i have associated to fbx file a texture map in this case both FBX and PNG files are converted to XNB but when i try to load these XNB files into my project the following problem occours "ContentLoadException Could not load Models maze1 asset as a non content file!" Note maze1 is the XNB file that was converted from FBX. How can I solve this problem? Thank you in advance |
7 | How to get asset folder path in android native activity? I am trying to create a small game with android native activity. I wish to load textures using stb image. I don't know how to get the path to assets folder. Is there any API to get path to apk directory so that I can use that to get textures? Thanks. |
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 | Playing Sounds and removing instances once they have played Android I am playing sounds in my application I have the following code sounds new HashMap lt String, MediaPlayer gt () Then when guys are created on screen they are given a sound. sounds.put("sounds" Integer.toString(ncount), MediaPlayer.create(this, R.raw.hit)) I want to remove the MediaPlayer from the hashmap like I do the enemies when they die sounds.get("sounds" Integer.toString(ncount)).setOnCompletionListener( new MediaPlayer.OnCompletionListener() public void onCompletion(MediaPlayer mp) sounds.remove("sounds" Integer.toString(ncount)) ) This errors out... how would I reference the sounds hashmap to remove the associated MediaPlayer when sound is complete? Thanks! |
7 | How does the rectangle bounds (x,y,width,height) in libgdx work? I cant work out how to use the rectangle bounds in libgdx I am currently using the superJumper example and have 2 or 3 examples with that are lt ! this is the pause button in the top right corner gt pause Bounds new Rectangle(320 64, 480 64, 64, 64) lt ! this is a rectangle resume button in the middle of the page in the menu that comes up when the pause button is pressed. gt resume Bounds new Rectangle(160 96, 240, 192, 36) Basically my question is aimed at the 360 64 and 160 96 because I don't know why this is used. I need to create a rectangle that covers the left side of the screen and the same on the right. I want to create some on screen buttons, I have already created the actions for these buttons and I have managed to get them to work but I can't move the rectangles to where I want. |
7 | Score won't save to Android in Game Maker Studio 1.4 I have oController as the first object to run when the game is opened. In oController's Game Start event I have the following code ini open(working directory quot SavedScores.ini quot ) var highscores ini read real( quot Highscores quot , quot Score quot , 0) ini close() global.LastScore highscores When the player has gotten their score, I use this code to save it if global.gameOver if global.LastScore 0 global.LastScore global.currentScore ini open(working directory quot SavedScores.ini quot ) ini write real( quot Highscores quot , quot Score quot , global.LastScore) ini close() else if global.currentScore gt global.LastScore global.LastScore global.currentScore ini open(working directory quot SavedScores.ini quot ) ini write real( quot Highscores quot , quot Score quot , global.LastScore) ini close() Whenever I relaunch the game on my phone, it won't load the score I got when I previously launched the game. Idk why it's not saving? |
7 | How to sell Android game if selling through Market is not available in your country Android Market doesn t allow developers from my country to sell app. From what I understand the only chance to make some profit is to place ads in my application. Does ads make a decent profit or is there some other way to earn money are there any other payments system available for Android to bypass Google s limitations? |
7 | Speed up loading of png files (used for textures) in Android OpenGL Game My game has a few texture atlases that need to be loaded (in my XHDPI folder they total 3.49MB) and on a top end device they don't take that long to load, however on a low end device they seem to take an age. An example would be my old Samsung Galaxy Ace which uses the MDPI folder for it's resources (total 1.51MB), this takes 16 seconds, which I personally consider far too long. Originally, I had a separate atlas for each sprite, so I merged the majority of my atlases into one big atlas after reading that it may speed things up. Unfortunately, it hasn't really made any difference to the load speed. This is how I'm loading my png files atlas BitmapFactory.decodeResource(view.getResources(), R.drawable.atlasimage) As the default load format is ARG B8888, I though I'd attempt to load them in RGB565 as this is supposed to be quicker to load and render as well as take up less memory. So I tried this BMFOptions new BitmapFactory.Options() BMFOptions.inDither false BMFOptions.inPreferredConfig Bitmap.Config.RGB 565 atlas BitmapFactory.decodeResource(view.getResources(), R.drawable.atlasimage, BMF Options) Unfortunately, although this does reduce the quality of the image, it doesn't reduce the load time and yields no noticible performance increase. Also, (and this may be expected), it doesn't reduce the memory footprint of my app. So my question is how can I optimise this so that my png's are loaded quicker (rendering speed increase not being as important at the moment as load speed). |
7 | Detecting image curve to move a truck on this surface I have an image background in surface view I want to move something according to black surface.But i can not do this using height of this image as it return same height.and one more thing bitmap.getPixel is also not working.and my background is moving.So what is the way to achieve this feat |
7 | App Programming Question Converting Code and Project Folders for the Smartphone's OS Compatibility I was thinking about how does the Angry Bird game for the iOS successfully converted into an Android compatible version. Does it involve using Phonegap or something? When making games for iOS, the programmer preferred XCode. For Android game app, the programmer preferred Eclipse IDE and a LibGDX engine library. Because of this, like Angry Birds for example, this game became compatible for the iOS, Android, and even on the desktop computer. The question is...how does it work? |
7 | How do I "reset" the color in OpenGl ES 1.0 1.1? In my 2D game I use glColor4f() to set the color and draw my screen border rectangles but when I try to start drawing my game objects, made up of a texture on a rectangular "quad", using GL10.GL TEXTURE 2D, GL10.GL VERTEX ARRAY and GL10.GL TEXTURE COORD ARRAY no GL10.GL COLOR ARRAY, it uses the "current color" from glColor4f(). My question is what do I need to set reset in OpenGl ES to re enable it to use the colors from the texture when I try to draw them? If I comment out the border drawing, so glColor4f() never gets called, the colors are fine. I'm not using double buffering. I read that once you set the color with glColor4f() it stays set, unless you possibly use glPushAttrib(GL CURRENT BIT), but I heard that that's expensive, time wise. |
7 | LibGDX cannot save to internal file I want to save the state of the game in a file, so I can read it at the next start. The Problem is, that I get a exception, if I try to save something internal. If I try to save it local all work fine. I save the file as a Json. Bird bird new Bird() bird.setName("Foo") bird.setSkin(new Texture("data foo.png")) bird.save(Gdx.files.internal("bird.json")) The save mthod Json json new Json() file.writeString(json.prettyPrint(this), false) Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException Error writing file bird.json (Internal) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 349) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 335) at com.buschmannmichael.fattybird.core.Bird.save(Bird.java 31) at com.buschmannmichael.fattybird.game.FattyBirdGame.create(FattyBirdGame.java 16) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java 137) at com.badlogic.gdx.backends.lwjgl.LwjglApplication 1.run(LwjglApplication.java 115) Caused by com.badlogic.gdx.utils.GdxRuntimeException Cannot write to an internal file bird.json at com.badlogic.gdx.files.FileHandle.writer(FileHandle.java 315) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 346) ... 5 more Whats the problem of LibGDX, where I should save the files, so I can run the game on android, desktop and html ? (I tested this method I showed above only on desktop, maybe it works on android but I want a solution for all platforms) Maybe someone can help me ) |
7 | Android opengles how to use glunproject How to use glunproject in my android app? I have the following parts in my engine A projection matrix A view matrix for the camera A model matrix for each of the objects in my world. This matrix is calculated from the parent objects model matrix and the objects own model matrix. These matrices are calculated from a translation, rotation and scale matrix. (this all works fine) These matrices are then multiplied and passed to my vertex shader. Now I understand glunproject needs the model matrix and the projection matrix and can caluclate a near and far 3d coordinate depending on the camera viewport settings ( for the near and far plane) Do I need to use glunproject for each of the objects in my world and then check if the ray produced by these near and far coords intersects my object? This seems quite expensive on the cpu? What is the proper use for glunproject |
7 | Android glsl discard problem Whenever I use discard or an if statement in my shaders, I get an error message with the text lt qgl2DrvAPI glAttachShader 398 gt GL INVALID VALUE I think this is a version problem, but I'm really not sure. |
7 | Game Development at iOS, Android and PC with OpenGL ES I'm beginning iOS apps development, and my aim is to make games to launch on App Store. But I want to know if it's possible to program a game on Xcode with OpenGL ES (C game logic), integrate it on iOS with ObjC, and with that same game code (OpenGL ES C ), implement it for Android with Java and to PC. I have great interest to publish the same game on App Store, Google Play and specially Steam, and intent to build my personal 2D engine API when I have more experience on graphic programming. Do you know where can I find material to learn this? |
7 | Is attribution sufficient for CC BY SA 3.0 licenced music in a commercial mobile game? I am in the process of developing a mobile game that I intend to sell on Google Play. I want to include a music licensed as Attribution ShareAlike 3.0 Unported (CC BY SA 3.0) If I attribute the author contributor of the music, am I allowed to sell my game without the same license? I would like to get opinions from people who have had experience in this situation. |
7 | How to Change default Mouse pointer on emulator in Android? I want to change default mouse pointer in Android emulator. I want to change it for my game to use different type of cursor.I am using AndEngine for my game development. Is there nay way to change default mouse cursor for my Application. Thanks in Advance |
7 | LibGdx Scalling sprites on Android I have a sprite that is a few buttons but need them in the center of the screen for all android devices. I tried setting it's location to the center of the screen by dividing the orthogonal camera by 2, but it doesn't help. Any simple way to fix this? |
7 | Game Loop delay the right way and game speed I am a newbie game developer. I am trying to find a right way to create my game loop. Consider following example. Simple Android Game I have a game with a simple gameplay bouncing ball. I want to have a control of the ball speed. Also I want my game to have the same framerate (framespeed) on all devices. Where the speed logic should be implemented ? In my case I have simple ball object with a velocity vector. I can change the velocity vector properties in order to make my ball move faster or slower, am I right ? The Main Loop. I have read a lot of about this part of a game. I found this article http gameprogrammingpatterns.com game loop.html . And decided to use this code example double previous getCurrentTime() double lag 0.0 while (true) double current getCurrentTime() double elapsed current previous previous current lag elapsed processInput() while (lag gt MS PER UPDATE) update() lag MS PER UPDATE render() I have a lot of questions about this example. I have the similar loop in my game. Override public void run() while (mIsRunning) processGameInput() updateGameState() drawGame() I cannot understand while update() is called while waiting for a constant delay ? Why not the render method ? Maybe I am missing something. Here is how my update for the ball looks like. public void updatePosition() mCenterX mVector.x mCenterY mVector.y As you could see, each time I increase the position of the ball by the value of the velocity vector. But as can guess, in case of using the example from the article, the update method will be called for instance 100 times. And the render method only once per 100 update method calls. So in this case I guess, I the ball will be changing its position lagging. My goal is to control the speed of the ball, for example from 0.1s 2s. How can achieve this ? Please help to understand this topic. Any help would be highly appreciated. |
7 | Where and how to check if game was developed with bought Unity3D licence (not cracked app)? We hired an external team from Eastern country. They built our mobile game app using Unity3d which we paid a lot of K. We asked them to only use the software with bought license, not cracked one, and they said they will do it. Now, we're ready to publish apps to official stores and I read on the net that guys from unity3d can always check if the app was made via bought license or via cracked software. If they discover it's been made with cracked software, they will ban the app and probably prosecute us. Where can we find such tool to confirm that our software was indeed made by 100 licensed unity3d piece of software? |
7 | How can I use imprecise accelerometer data for controls? I want to rotate an object with respect to the phone's position. I use the accelerometer output to detect orientation float roll Gdx.input.getRoll() float pitch Gdx.input.getPitch() float azimuth Gdx.input.getAzimuth() Vector3 accel new Vector3(accelX, accelY, accelZ) bat.transform.setToRotation(0f, 1f, 0f, pitch) bat.transform.setFromEulerAngles(azimuth, pitch, roll) However, the accelerometer data fluctuates so strongly that the object jitters. How can I deal with this? |
7 | Should Starting a Quick Game via Google Game Services be Iterated? I have been following this tutorial for Google Play Game Services. I am a little unclear as to if the room matching algorithm should be looped or not. Can I just initialize this process once and let it time out? Or by iterating through it is it somehow rechecking it? If anyone had the approximate timeout that would be great as well. The problem stems from the fact that even when both phones are signing into the Game Services (at virtually the same time, my friend and I logged in), the room is not registering multiple people. One time my friend's phone even entered the game map, showing that he somehow was able to progress from the room initialization process. Relevant screen update methods which I am starting this matchmaking process Override public void update(float deltaTime) game.options.updateTiles() if(!isInitiated) startQuickGame() private void startQuickGame() auto match criteria to invite one random automatch opponent. You can also specify more opponents (up to 3). if(game.mGoogleClient.isConnected() amp amp !isInitiated) Bundle am RoomConfig.createAutoMatchCriteria(1, 3, 0) build the room config RoomConfig.Builder roomConfigBuilder RoomConfig.builder(Network.getInstance()) roomConfigBuilder.setMessageReceivedListener(Network.getInstance()) roomConfigBuilder.setRoomStatusUpdateListener(Network.getInstance()) roomConfigBuilder.setAutoMatchCriteria(am) RoomConfig roomConfig roomConfigBuilder.build() create room Games.RealTimeMultiplayer.create(game.mGoogleClient, roomConfig) go to game screen this.mRoom Network.getInstance().getRoom() if(this.mRoom ! null amp amp this.mRoom.getParticipants().size() gt 2) game.setScreen(new MultiGameScreen(game, this.mRoom)) isInitiated true else game.mGoogleClient.connect() |
7 | What debugging info should I put in the "About" box I'm developing an Android game with the idea of publishing it, and I wonder what info should I put in the "About" dialog that many main menus have. The idea is to make bug report and debugging easier. Users can click in the "About" box and read the details of their device, and include them in any bug report they send me I know Google sends relevant device data to the developer when there's a crash, but I'm thinking in bugs that not necessarily end with an abnormal program termination. So far, I've added API number of device, screen size, screen density, and number of processors. My current "About" screen is something like this Game titleGame iconAPI versionScreen sizeScreen densityNumber of processors (just in case, because game uses threading)Game version numberDeveloper e mailCopyright information If anyone has experience publishing and maintaining an app, specially in Android, I want to know what can I add there to make user reporting and debugging easier. |
7 | is there a formula to know how many enemies i can place before jumping character? My game is very similar to the hidden game in chromes web browser. I have a character that needs to jump over incoming enemies. Is there any way i can know when to send an incoming enemy? Some of the factors to take in to account i guess are the speed of enemies, height of jump, speed of jump, and dimensions of bitmaps (that represent character, and enemies). Thanks |
7 | What do you use to support multiplayer turn based network game for iOS and Android games? If I'm doing a turn based card game, what kind of technique do you use to support multiplayer gameplay over Internet? Is it socket? If it's socket, which SDK (CoronaSDK etc.) can provide solid socket library? Can Unity3D can be used solely to support what I need without using other socket servers like SmartFox or Electro? |
7 | Game Development at iOS, Android and PC with OpenGL ES I'm beginning iOS apps development, and my aim is to make games to launch on App Store. But I want to know if it's possible to program a game on Xcode with OpenGL ES (C game logic), integrate it on iOS with ObjC, and with that same game code (OpenGL ES C ), implement it for Android with Java and to PC. I have great interest to publish the same game on App Store, Google Play and specially Steam, and intent to build my personal 2D engine API when I have more experience on graphic programming. Do you know where can I find material to learn this? |
7 | drawing a horizon sky in OpenGL ES 2.0 I want to render a sky My camera is at the origin, and I want there to be a white background for all world coordinates with z lt 0 (would normally be considered y 0, but I have a different coordinate system via glLookAt()). I thought I may be able to do this in the fragment shader by multiplying the inverse MVP matrix with the corresponding clip space (?) coordinate (I compute that matrix on the CPU each frame by calling Matrix.invertM()). To get my vertices into the fragment shader, I use a varying variable (I wasn't sure if I could access gl Position in the fragment shader) and passed the position right through not sure if my syntax is right (see below) Vertex Shader attribute vec4 position varying vec4 vp void main() gl Position position vp position Fragment Shader precision mediump float uniform mat4 inverseMatrix varying vec4 vp void main() vec4 inversePosition inverseMatrix vp if (inversePosition.z gt 0.0) gl FragColor vec4(0,0,0,1) else gl FragColor vec4(1,1,1,1) Question Does this approach seem sane? Should I use some other approach that doesn't involve multiplying each fragment coordinate with the inverse MVP matrix? |
7 | Google Play Services and COPPA Compliance I hesitated to ask this question here, since i'm not sure there is a definitive answer (but there can be, maybe i missed it). I'm implementing Google Play Services for a game on Android target at all audiances, including children under 13. So, I was wondering, does the use of achievements comply with COPPA rules? On one hand the app is not using personal informations (only reporting progress of achievements, which can be score, or number of games... nothing personal), BUT on the other hand, the authentication itself to google play games seems to be personal information sent to the internet (the auth process itself). I'm already using admob with the tagForChildDirectedTreatment. So i was wondering, if achievements (and maybe leaderboards) need specific steps to comply with COPPA, is there something like this tagForChildDirectedTreatment but for achievements, ... or do I have to show a panel to get parental authorization? Or maybe set the google play connection as optional, not default as written somehow here? The reason why i'm so concerned by this is this little 16000 fine i read several times, in case you don't respect whatever has to be respected. |
7 | Relative and absolute position with sprites in libgdx In libgdx, can i add a sprite as children of another an set it with the relative coordinates of the father and not the stage? Like in HTML when you add controls they are relative to its parent, but here i want it with sprites, i add the children in a Group class but the coordinates are absolute (relative to the stage) |
7 | What image format supports transparency in Android? I want to show an apple on screen but the image has a white background and it doesn't blend with the background of a tree. Is there any image format in which only the red apple is displayed? |
7 | How do i prevent IAP abuse using restoring purchases in an online game? Lets say i have a mobile mmorpg (ios android) where you can purchase premium currency using IAP's... how do i actually prevent the following case Player purchases premium currency Server side checks if the purchase is valid, grants the user premium currency Player uses the premium currency to buy some items Player restores his purchase on google play and gets his money back Result Player didnt spended money and still got what he wanted As long as i know theres no option to prevent that case in google playstore or ios app store... Users can restore purchases within 48 hours after the purchase. So what could i basically do to prevent this, aslong as i dont use 3rd party payment services like PayPal ? |
7 | Best way to manage sprite sheets on Android using NME I'm creating a 2D game for mobile touchscreen devices, specifically Android and iOS. I would like to know what is the best way (regarding performance and best practices) to manage sprite sheets. Should I create different sprite sheets (for ldpi, mdpi and hdpi) and then scale according depending on the screen resolution or there is a better solution?. I know that maybe the solution that someone could provide me would be platform independant but I'm using the NME framework (http www.nme.io ), perhaps you know a good solution using this framework. |
7 | Error rendering map android I'm trying to read this text file and render the corresponding tiles on the screen. The code for reading the map is as follows private void loadMap(InputStream is) throws IOException ArrayList lt String gt lines new ArrayList lt String gt () int width 0 int height 0 BufferedReader reader new BufferedReader(new InputStreamReader(is)) while (true) String line reader.readLine() if (line null) reader.close() break if (!line.startsWith("!")) lines.add(line) width Math.max(width, line.length()) height lines.size() for (int j 0 j lt 18 j ) String line (String) lines.get(j) for (int i 0 i lt width i ) if (i lt line.length()) char ch line.charAt(i) Tile t new Tile(i, j, Character.getNumericValue(ch)) tiles.add(t) The first problem I have is with Character.getNumericValue(ch) as this does not seem to be doing anything, resulting in a NullPointerException. When I remove it and replace it with either a 1 or a 2 I'm able to render the tiles onto the screen but somehow the spaces in between the digits are interpreted as tiles, resulting in a continuous block of tiles eg in the second line with 1s results in tiles beginning from the left margin up until the last 1. How can I fix this? |
7 | Function call to AndroidJabaObject to an instance of com.prime31.PlayGameServicesPlugin causes the application to stop responding Using Prime31 PlayGameServices attempting to call 'authenticate' causes the game to stop responding very soon after. There isn't much I can show as there's literally no logs showing up in logcat. Is there any way I can debug this? I did notice 'enableDebugPrints' on the AndroidJavaObject was 'false' and I don't know how to set it to true, which might help with prints? I've tried catching an exception but that hasn't worked. |
7 | License for a Breakout This may not be an appropriate question for gamedev.stackexchange.com. I'd like to make a basic Breakout game with Unity. I'd also like to sell it on the Mac App Store, iOS App Store, Google's Play Store, Windows 8 Store etc. I'm not sure however if that will cause trouble with Copyright. I asked Google but I didn't find any helpful results. Can I use the game concept without buying a license? I know that there are plenty of games with the same concept on various platforms, I just want to be certain. |
7 | How can you check your users' unlocked achievements (Google Play Game Services)? Is it possible to see how many of your users have unlocked certain achievements on the Google Play Developer console? This information would be very useful. I guess that one could achieve this through integration with Google Analytics but I was wondering if there was a simpler way to get this data. |
7 | Javascript board game looking for optimization I posted this question on stackoverflow before but received no answers so I decided to post it here and see if someone could suggest me something. I'm working on a html javascript game for android. It's a board game which does the following. It has tiles of different colors and user can place one tile (chosen programatically) on the board. If we get 4 or more tiles of the same color shape we score some points and these tiles will disappear. The tiles above the removed tiles will replace them and new tiles will be added to the empty places. The image below shows how it works (this is just an example, the real board can have different dimensions) The Tiles are lt img gt elements with their ids stored in an array which I use to check for matches and replacement. It all works pretty well but once the new tiles are added to board I need to examine the whole board to check if new matches are avalable. And I want some advice here, because examining the whole board can be really slow. Is there a way I can do this efficiently? Here's what I thought about doing Given the previous example, I thought about examining only the elements in the red area, i.e. only the elements that have been moved or added. It can be effective if the tiles move vertically, as I'll only have to check the moved added tiles and it'll give me the new matches. But in case where I remove tiles horizontally it can be problematic, because if these tiles are at the bottom i'll have to examine the whole board and i confront the same problem. Any advice or suggestion will be appreciated. Note I didn't add any code because it simply consists of checking the lines and columns for a given tile and look for matches. But if needed I can provide it. EDIT Adding horizontalMatchCheck function that for a given index checks for matches horizontally. It's the same thing for vertical check. function horizontalMatchCheck(itemId) hArray new Array() if (rightMatch(itemId)) var index itemId 1 hArray.push(itemId 1) while (rightMatch(index)) hArray.push(index 1) index if (leftMatch(itemId)) var index itemId 1 hArray.push(itemId 1) while (leftMatch(index)) hArray.push(index 1) index if gt 4 matches found I replace the indexes with 5 (because no other tile can have this id) which'll then be removed and shifted. if (hArray.length gt 3) hArray.push(itemId) for (var i 0 i lt hArray.length i ) board hArray i items.length else hArray new Array() function rightMatch(pos) return (!isRight(pos) amp amp board (pos 1) current) ? 1 0 function leftMatch(pos) return (!isLeft(pos) amp amp board (pos 1) current) ? 1 0 |
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 | How do I get and install the Android SDK on my Ubuntu OS? I heard that it would be a lot easier to do java type games and then move on to Android gaming? I AM a total beginning but with motive and I have been reading about it from several sources, including similar questions on this site alone. But I need to know specific things from experienced users. As for getting the SDK and Eclipse on the computer, I'm having trouble with it, I am running Ubuntu btw so exe files are useless. But I have tired terminal use but I kind of failed because I don't think the SDK and Eclipse are installed, just downloaded. Ubuntu users especially, I can use help from you seeing how complicated Ubuntu can be compared to windows "click install" setups. Also if you guys really suggest me learning Java first (which is still a big question cause I don't want to waste time with something I don't want to really use, but getting the feel of gaming is pretty important I know) I am looking at this tutorial http zetcode.com tutorials javaswingtutorial And it talks about using swing toolkit, but idk how to get that exactly, I tried searching. Sorry for the noobness, but gotta start somewhere and I'm new to this site so I'm really hoping you guys can really help me. I want to make simple games to put on the android market, and then advance. So going to the tutorial above, it just kind of starts with giving me coding and whatnot which is fine, just copy it but idk where exactly to do all this on (Swing toolkit?) so I can't even start with that. But really I want help getting this SDK and Eclipse plugins on my computer and then I can continue with this guide www.rbgrn.net content 54 getting started android game development Which is the main guide that I probably should follow, and would be great if some expert skims it a little at least to see if I should start with that guide and skip the java. But again, I'm stuck on the SDK stuff. Sorry for the long questions, I am new and I really want to get out of this beginner stage, it's the worst part. Tank you to all and if you want my facebook or AIM to help me through with IM to at least get this SDK and stuff installed fine with Ubuntu OS, ask please ( |
7 | Download and open an zip file ingame on unity for android I would like to know if it is possible to have a game that would download a rar or zip file from a website and extract it to the internal storage for use, and if it is a good option since i have to use a directory structure to open fbx models that have the texture on a folder with the same name of the fbx. The App is made for android and the files should not be bigger than 30mb. |
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 | How should I store a Game Database on Android? I'm looking at creating a game for Android and while I have most of the ins and outs worked out, the one thing I'm struggling with is how to store data for the game. Ultimately, the game will be based off of a lot of pre defined data and statistics so the obvious choice to me would be something like SQLite, but as I'm pretty new to the realm of Android and Game Development, I'm not 100 certain if this is the right route to follow. The data will be general pre defined data as well as player data (along the lines of careers stats what place finished, etc). I was wondering if there was a better best practice solution that wasn't SQLite and that would provide said functionality and if so, could you point me in the right direction? |
7 | Advantages and disadvantages of libgdx I've been an android developer for a while and am thinking about getting into gaming. While looking for a game dev framework, I thought libgdx provides very friendly documentation and functionality. So I would like to use it if there is no big obstacle. But when I tried to see how many developers employ this library, I could find not that many. Is there anything wrong with this library? In other words, I would like to know its advantages or disadvantages from any experienced developer. UPDATE After reviewing its documentations and trying to build simple games with libgdx, I decided to go with it as its documentations are good enough and its community is very active. What I liked the most is that it provides a bunch of demo games that I can learn a lot from. |
7 | Pixel perfect collision detection between sprite and animated sprite I am trying to make a collision between a sprite and an animated sprite. The animated sprite is the main character of the game. The problem I am facing is that when another sprite collides with the main character, it collides with the transparent bounding area around the character. How should I perform collision detection between the actual pixels of the character and any other obstacle sprite? |
7 | If I want to create game for mobile and tablet on android and ios, which aspect ratio or screen resolution should I use? Now my game is currently use 3 4 aspect ratio ,which is 480 640 , so my game has the letterbox (I don't like stretch) on my android mobile and my friend mobile. I don't like letterbox, so I have just change color of my letter box to the color that blend with my game background, but I don't like it either. So now I think about change aspect ratio and screen resolution of my game. how about 480x800 ? |
7 | Remove a body when touched in LibGDX(Box2D) I am using LibGDX to create a new project. What i am trying to do is, i load bodies from a tmx file into levels which works fine. The bodies also has a sprite with them. The problem is, is i would like to allow the user to touch certain bodies on the scene. When they touch the body they will be able to delete or remove it from the scene. Is there anyway i can do this in LibGDX? |
7 | libgdx Texture not appearing sometimes When I run the App the Ball moves sometimes downwards, but sometimes its not moving. I dont change anything on script. What I want is the ball should come from top outside of the screen, but when its visible in screen it should get an random xSpeed. To test it I added first the bomb in the middle of the screen. But as I said the Ball is not showing sometimes. I run the game on my samsung galaxy s6 edge and the ball is there. Then when I run again it's not there. That's how I coded. private static final int SPRITE SIZE 32 It has 32px width and height private static final int SPRITE COUNT 4 there are 4 sprites private static final float MAX SPEED 1f maxspeed private static final float MIN SPEED 0.25f min speed private Vector2 position private Animation anim private Random random private float speedX, speedY public Bomb() random new Random() int rand random.nextInt(2) TextureRegion tmp new TextureRegion(Asset.sprites, SPRITE SIZE SPRITE COUNT, rand SPRITE SIZE) anim new Animation(tmp, SPRITE COUNT, 0.75f) position new Vector2((MainGame.WIDTH 2) (SPRITE SIZE 2), MainGame.HEIGHT) speedX 0 speedY MAX SPEED public void update(float dt) anim.update(dt) if(speedX 0) if(position.y SPRITE SIZE lt MainGame.HEIGHT) speedX random.nextFloat() (MAX SPEED MIN SPEED) MIN SPEED position.add(speedX, speedY) public void render(SpriteBatch sb) sb.begin() sb.draw(anim.getFrame(), position.x, position.y) sb.end() EDIT Maybe here's a problem? Asset.java public class Asset public static Texture sprites public static void init() sprites new Texture(Gdx.files.internal("sprite.png")) public static void dispose() sprites.dispose() Animation.java public class Animation private Array lt TextureRegion gt frames private float maxFrameTime private float currentFrameTime private int frameCount private int frame public Animation(TextureRegion region, int frameCount, float cycleTime) frames new Array lt TextureRegion gt () int frameWidth region.getRegionWidth() frameCount for(int i 0 i lt frameCount i ) frames.add(new TextureRegion(region, i frameWidth, 0, frameWidth, region.getRegionHeight())) this.frameCount frameCount maxFrameTime cycleTime frameCount frame 0 public void update(float dt) currentFrameTime dt if(currentFrameTime gt maxFrameTime) frame currentFrameTime 0 if(frame gt frameCount) frame 0 public TextureRegion getFrame() return frames.get(frame) public void dispose() for (int i 0 i lt frames.size i ) frames.get(i).getTexture().dispose() |
7 | AndEngine Making Chase Camera Follow Player I am playing around with the AndEngine Race Game example. I am trying to make the camera follow the car as the player moves around. The Tile Map is larger than the player's screen but the camera does not follow the car when it moves. Here's my code this.mScene new Scene() this.mScene.setBackground(new Background(0, 0, 0)) Tiled Map Test try final TMXLoader tmxLoader new TMXLoader(this.getAssets(), this.mEngine.getTextureManager(), TextureOptions.BILINEAR PREMULTIPLYALPHA, this.getVertexBufferObjectManager(), new ITMXTilePropertiesListener() Override public void onTMXTileWithPropertiesCreated(final TMXTiledMap pTMXTiledMap, final TMXLayer pTMXLayer, final TMXTile pTMXTile, final TMXProperties lt TMXTileProperty gt pTMXTileProperties) We are going to count the tiles that have the property "box true" or "boxBool true" set. if(pTMXTileProperties.containsTMXProperty("box", "true")) SpeedsterGameActivity.this.numBoxes ) Load the TMX file into an Object this.mTMXTiledMap tmxLoader.loadFromAsset("tmx level3.tmx") this.runOnUiThread(new Runnable() Override public void run() Toast.makeText( SpeedsterGameActivity.this, "Box count in this TMXTiledMap " SpeedsterGameActivity.this.numBoxes, Toast.LENGTH LONG).show() ) catch (final TMXLoadException e) Debug.e(e) Get the first TMX Layer and add it to the scene final TMXLayer tmxLayer this.mTMXTiledMap.getTMXLayers().get(0) this.mScene.attachChild(tmxLayer) Make the camera not exceed the bounds of the TMXEntity. this.mBoundChaseCamera.setBounds(0, 0, tmxLayer.getHeight(), tmxLayer.getWidth()) this.mBoundChaseCamera.setBoundsEnabled(true) Debugging stuff Debug.i( "Game Info", "Height amp Width " tmxLayer.getHeight() " x " tmxLayer.getWidth() ) int maxTextureSize new int 1 GLES20.glGetIntegerv( GLES20.GL MAX TEXTURE SIZE, maxTextureSize, 0) Debug.i("Game Info", "Max texture size " maxTextureSize 0 ) Calculate the coordinates for the face, so its centered on the camera. final float centerX (CAMERA WIDTH this.mVehiclesTextureRegion.getWidth()) 2 final float centerY (CAMERA HEIGHT this.mVehiclesTextureRegion.getHeight()) 2 Create the sprite and add it to the scene. final AnimatedSprite player new AnimatedSprite(centerX, centerY, this.mVehiclesTextureRegion, this.getVertexBufferObjectManager()) this.mBoundChaseCamera.setChaseEntity(player) this.mPhysicsWorld new FixedStepPhysicsWorld(30, new Vector2(0, 0), false, 8, 1) |
7 | Keep cube spinning after fling So I've been trying to get started with game development for Android using Unity3D. For my first project I've made a simple cube that you can spin using touch. For that I have the following code using UnityEngine using System.Collections public class TouchScript MonoBehaviour float speed 0.4f bool canRotate false Transform cachedTransform public bool CanRotate get return canRotate private set canRotate value void Start () Make reference to transform cachedTransform transform Update is called once per frame void Update () if (Input.touchCount gt 0) Touch touch Input.GetTouch (0) Switch through touch events switch (Input.GetTouch (0).phase) case TouchPhase.Began if (VerifyTouch (touch)) CanRotate true break case TouchPhase.Moved if (CanRotate) RotateObject (touch) break case TouchPhase.Ended CanRotate false break bool VerifyTouch (Touch touch) Ray ray Camera.main.ScreenPointToRay (touch.position) RaycastHit hit Check if there is a collider attached already, otherwise add one on the fly if (collider null) gameObject.AddComponent (typeof(BoxCollider)) if (Physics.Raycast (ray, out hit)) if (hit.collider.gameObject this.gameObject) return true return false void RotateObject (Touch touch) cachedTransform.Rotate (new Vector3 (touch.deltaPosition.y, touch.deltaPosition.x, 0) speed, Space.World) The above code works fine. However, I'm wondering how I can keep the cube spinning after the user lifts his finger. The user should be able to "fling" the cube, which would keep spinning and after a while would slowly come to a stop due to drag. Should I do this using AddForce or something? I'm really new to this stuff so I'd like it if you guys could point me in the right direction here ) . |
7 | How to change modify or animate an existing OpenGL object on Android? I maybe know understand it all a little bit better so i thoug i make a new shorter question to eventually get an answer. Get back or delete an existing OpenGL object, then change it and draw at new. How? So if and Admin reads this post, he can feel free to delete it. I'm working on OpenGL since a Week, so i'm new to the most stuff. (also my englisch isn't the best. Hop you can understand the most anyway) So i'm working on an Tamagotchi App for a school project and want to make it with OpenGL. I allready came this far But now i want to animate things. My mind told me that it shoud be possible to change or modify an existing OpenGL object. In my situation there are 3 opjekts Body Eyes Mouth For example her is my code from the mouth public class GLMouth private int points 1000 private float vertices 0.0f,0.0f,0.0f private FloatBuffer vertBuff private FloatBuffer vertBuff2 public GLMouth() vertices new float points 2 for(int i 0 i lt (points 3) i 3) double rad (Math.PI i) points vertices i (float)Math.cos(rad) vertices i 1 (float)Math.sin(rad) vertices i 2 0 ByteBuffer bBuff ByteBuffer.allocateDirect(vertices.length 4) bBuff.order(ByteOrder.nativeOrder()) vertBuff bBuff.asFloatBuffer() vertBuff.put(vertices) vertBuff.position(0) vertices new float points 2 for(int i 0 i lt (points 3) i 3) double rad (Math.PI i) points vertices i (float)Math.cos(rad) vertices i 1 (float)Math.sin(rad) vertices i 2 0 bBuff ByteBuffer.allocateDirect(vertices.length 4) bBuff.order(ByteOrder.nativeOrder()) vertBuff2 bBuff.asFloatBuffer() vertBuff2.put(vertices) vertBuff2.position(0) public void draw(GL10 gl) gl.glPushMatrix() gl.glTranslatef(0.0f, 1.0f, 0.0f) gl.glScalef(1.8f, 0.15f, 1.0f) gl.glColor4f(0.0f,0.0f,0.0f, 1.0f) gl.glVertexPointer(3, GL10.GL FLOAT, 0, vertBuff) gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glDrawArrays(GL10.GL TRIANGLE FAN, 0, points 2) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glPopMatrix() gl.glPushMatrix() gl.glTranslatef(0.0f, 1.0f, 0.0f) gl.glScalef(1.8f, 1.0f, 1.0f) gl.glColor4f(0.0f,0.0f,0.0f, 1.0f) gl.glVertexPointer(3, GL10.GL FLOAT, 0, vertBuff2) gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glDrawArrays(GL10.GL TRIANGLE FAN, 0, points 2) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glPopMatrix() In my renderer i just creat a mouth object and then draw it with mouth.draw. So i thought i have allready drawn the mouth and now i can cange for example the gl.glScalef(1.8f, 0.15f, 1.0f) from that existing mouth to zero with some time in between to let it look like the mouth is closing. But how can i do that? I don't find anything with google, mostly because i don't know what i have to look up. If i understand OpenGL right, than it will just draw new mouths over the original. edit Or it is a question about where is the opjekt? Can i save it an take it back (delete it etc) and draw it new with other properties. |
7 | SDL2 and density independent pixel I'm currently using SDL2 on Android and that's my first experience with that library (to be honest, mainly chosen because I'd like to learn it). What is puzzling me is how to deal with different resolutions and density independent pixels, for I cannot figure out which is the recommended approach to create images and let them look decently on screen on the most of the devices. Unfortunately, googling around I've not been able to find a decent example or a bunch of information sufficient to clarify the doubts. It seems that the most common suggestion is to choose a fixed size virtual resolution for the content rectangle, thus draw on top of it and finally resize it to the actual one, but it would be appreciated to know if this one is really a widely used approach and if there are some others that are more suitable. Thank you. |
7 | Dragging an object by touching on Android I am trying to move and object by touching it and dragging. I am testing it on my Samsung Galaxy SIII. I have used the following code. For some reason it moves faster than my finger. It should always be beneath my finger. What is wrong? (note I haven't done the "only move object if you touch onto it" part, so right now it moves where ever I touch) pragma strict var speed float 1 function Start () function Update () if (Input.touchCount gt 0 amp amp Input.GetTouch(0).phase TouchPhase.Moved) Get movement of the finger since last frame var touchDeltaPosition Vector2 Input.GetTouch(0).deltaPosition var touchPosition Vector2 touchPosition.Set(touchDeltaPosition.x, touchDeltaPosition.y ) Move object across XY plane transform.position Vector2.Lerp(transform.position, touchPosition, Time.deltaTime speed) |
7 | Keeping Android Screen bright during Game I have a game that uses the accelerometer to move a guy back and forth on the screen. After a few seconds the screen goes dim. Is there any way to keep it alive and bright during the game activity? |
7 | AndEngine Font Issue I am learning AndEngine. I am displaying Hello world using this code public class myactivity extends SimpleBaseGameActivity private final int CAMERA WIDTH 320 private final int CAMERA HEIGHT 480 private Camera m Camera private Scene m Scene private Font font private Text text Override public EngineOptions onCreateEngineOptions() m Camera new Camera(0, 0, CAMERA WIDTH, CAMERA HEIGHT) EngineOptions en new EngineOptions(true, ScreenOrientation.PORTRAIT FIXED, new RatioResolutionPolicy( CAMERA WIDTH, CAMERA HEIGHT), m Camera) return en Override protected void onCreateResources() determine the density WindowManager windowManager (WindowManager) getSystemService(WINDOW SERVICE) Display display windowManager.getDefaultDisplay() DisplayMetrics displayMetrics new DisplayMetrics() display.getMetrics(displayMetrics) int density (int)(displayMetrics.density) scale desired size 25 by density int fontSize (int) (25 density) font FontFactory.createFromAsset(this.getFontManager(), this.getTextureManager(), 1024, 1024, this.getAssets(), "times.ttf", fontSize, true, android.graphics.Color.BLACK) font.load() Texture fontTexture new BitmapTextureAtlas(1024, 1024, TextureOptions.BILINEAR PREMULTIPLYALPHA) font new Font(fontTexture, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL), fontSize, true, Color.WHITE) mEngine.getTextureManager().loadTexture(fontTexture) mEngine.getFontManager().loadFont(font) Override protected Scene onCreateScene() m Scene new Scene() m Scene.setBackground(new Background(Color.WHITE)) text new Text(0, 0, font, "Hello Android", this.getVertexBufferObjectManager()) m Scene.attachChild(text) text.setPosition(CAMERA WIDTH 2 (text.getWidth() 2), CAMERA HEIGHT 2 (text.getHeight() 2)) return m Scene It is displaying the font like this As you can see that pixels are stretching and font is looking ugly with too much pixelation. How do I display proper font text with no pixelation or add anti aliasing to the font? |
7 | How to scroll background image Android App Basically, I have a main menu, and I would like the background image to scroll (parallax I believe is the term? Like the Angry Bird's title screen background). However, I'm used to just having a variable iterate (x ) and setting that as the x value so the image scrolls. So is there any way to confer variables and such between xml and my java files so I can use iteration? Or can I skirt this completely somehow? |
7 | Touchable Hud with Actors in Libgdx I am writing a Tower Defense for Android. Right now my LevelScreen contains a Background Actor which is pan able and some zones to buy Towers after buying them you can upgrade them further. When you click a Zone or a Tower, a small overlay on the bottom appears (another actor) click it to buy. My main Problem was that the overlay stayed where you clicked and didn't move when you pan the Screen. I solved this by changing the overlay's draw method to batch.setProjectionMatrix(game.batch.getProjectionMatrix()) batch.draw(texture,actorX,actorY) batch.setProjectionMatrix(levelScreen.stage.getCamera().combined) I set it backwards for further Actors who should stay where they are Towers for example but I kinda don't know what I am really doing. I am now only able to fire the touchDown Event on these actors when I pan to the bottom left of the Screen and click where the Actor's Icon is. I tried a few things Adding another Stage as a HUD(I couldn't Access the lower stage anymore or the other way around) Moving the actor.x and actor.y along (I was unable to even find where the actor went) Adding another camera (led to nothing) Updating the actors Position using stage.getCamera().unproject(myPoint) (same as when I tried to move the actor) So, which is a good way to implement what I look for? Basically, TL DR I am looking for a way of letting some Actors stay relative to Screen while moving some Actors with the world while panning around. I am pretty sure there a similar questions but None of them really helped me and I have restricted Internet Access (for example I can't Access badlogicgames.com). |
7 | Lua or C in Cococ2d x I am going to use Cocos2d x to make a game for Android and ios, but my question is, do I use the Lua integration or only c , I see Lua useful here because the compilation thing. Or do I use only Lua for the configuration, save data and things in runtime? I don t know if using Lua for the whole game is the right thing Can anyone help me with this question and why use it or not? Thanks |
7 | Physics for Android Game I'm making a 2D game for the Android phone, one that involves falling balls. I want to use a physics engine to properly simulate the balls falling and hitting other objects. I'm currently using Phys2D, but when the game runs in the emulator it doesn't look natural slow and rough. Course, I don't know if this is because of the emulator or Phys2D seeing as how I don't own an Android phone (A real drawback not being able to test on the actual phone, I know, but I can't afford a smartphone). Anyways, do you think the game would run faster and smoother on an actual android phone, or is it the engine I'm using, or how I'm using it. If it's the engine, any recommendations on Java physics engines? UPDATE If you want to test the game yourself, you can find the rough prototype here http bpcp.angelfire.com BallDrop.apk |
7 | Make LibGDX game responsive to different phone screen sizes? I've been experimenting with small games to learn design concepts, LibGDX, and Box2D. I am wondering how you would implement "responsiveness," so to say. For example, this is the rendering part of my game and its just drawing to coordinates. https github.com Elsealabs Stacker blob master com elsealabs stacker ScreenGame.java For example I'd like it to look good on Android phones of different resolutions or if the user resizes it on desktop. I am asking about design patterns or practices that would make this possible. Any solutions I can think of seem like they wouldn't scale or would over complicate the game. If you know of any articles or design practices that cover this topic, or have any of your own knowledge, or example LibGDX Java games, I'd love to see them. |
7 | is there a formula to know how many enemies i can place before jumping character? My game is very similar to the hidden game in chromes web browser. I have a character that needs to jump over incoming enemies. Is there any way i can know when to send an incoming enemy? Some of the factors to take in to account i guess are the speed of enemies, height of jump, speed of jump, and dimensions of bitmaps (that represent character, and enemies). Thanks |
7 | How should I structure my classes to allow for multithreaded simulation? In my game, there are plots of land with buildings (houses, resource centers). Buildings like houses have tenants, rooms, add ons, et cetera, and there are several values that have to be simulated based on all these variables. Now, I'd like to use AndEngine for the front end stuff, and create another thread to do the simulation calculations (perhaps also later include AI in this thread). This is so that one whole thread doesn't do all the work and cause problems such as blocking. This introduces the problem of concurrency and dependency. The currency problem is my main UI thread and the calculation thread would both need to access all the simulation objects. So I have to make them thread safe, but I don't know how to store and structure the simulation objects to enable that. The dependency problem is that in order to calculate values, my calculations depend on other objects' values. What would be the best way to link up my tenant object in the building with my calculations? Hard code it into the tenant class? What is a good way to do "store" algorithms so they are easily tweaked? A simple lazy way would be to bung everything into a class which holds all the object, such as plots of lands (who in turn hold the buildings, et cetera). This class would also hold game state such as the technology available to the user, object pools for things such as sprites. But this is a lazy and dangerous way, correct? Edit I was looking at Dependency Injection, but how well does that cope with like a class that holds other objects? i.e, my plot of land, with a building, which has a tenant and a host of other values. DI looks like a pain in the bum with AndEngine as well. |
7 | Use large image individually, or in TextureAtlas? Does it make any sense to include a large image (with dimensions of say 1920x1080) in a TextureAtlas and then use it with libgdx for example? Or should I rather use it individually and include the .png file into the assets folder as it is? Thank you. |
7 | How to get drawn Image width height on the screen with openGL ES on Android? I need to know how to get drawn image length and width. I have this code so far where I draw Radar in left top corner with hard coded coordinates int SRC R.drawable. item ... float vertices 0f, 0f, 0.0f, 0f, 2.0f,0.0f, 2.0f,0f, 0.0f, 2.0f,2.0f,0.0f ... addRadarToView(0,240) ... public void addRadarToView(float x, float y) this.x x this.y y ... private void updateScreenData(float screenWidth, float screenHeight) takes screen Height and Width this.mScreenWidth (screenWidth gt 0) ? screenWidth 1f this.mScreenHeight screenHeight wRatio 10f mScreenWidth hRatio mScreenHeight 10f Override public void loadTextures(GL10 gl) Log.e(LOG TAG, "loadTextures") InputStream is is mContext.getResources().openRawResource( SRC) Bitmap bitmap BitmapFactory.decodeStream(is) try is.close() is null catch (IOException e) gl.glGenTextures(TEXTURE COUNT, textures, 0) gl.glBindTexture(GL10.GL TEXTURE 2D, textures 0 ) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE MAG FILTER, GL10.GL LINEAR) gl.glTexParameterf(GL10.GL TEXTURE 2D, GL10.GL TEXTURE MIN FILTER, GL10.GL LINEAR) GLUtils.texImage2D(GL10.GL TEXTURE 2D, 0, bitmap, 0) bitmap.recycle() protected void drawRadar(GL10 gl) gl.glPushMatrix() try float transx (wRatio (x)) float transy (mScreenHeight wRatio) (wRatio (y)) 1 hRatio Log.e(LOG TAG, "transx " transx " transy " transy " sprite.x " sprite.x " sprite.y " sprite.y) gl.glTranslatef(transx, transy, 0.0f) draw gl.glBindTexture(GL10.GL TEXTURE 2D, textures 0 ) gl.glTexCoordPointer(2, GL10.GL FLOAT, 0, floatBufferArray mFrame ) update() gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glEnableClientState(GL10.GL TEXTURE COORD ARRAY) gl.glVertexPointer(3, GL10.GL FLOAT, 0, vertexBuffer) gl.glDrawArrays(GL10.GL TRIANGLE STRIP, 0, vertices.length 3) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glDisableClientState(GL10.GL TEXTURE COORD ARRAY) catch (NullPointerException e) gl.glPopMatrix() I used addRadarToView(0,240) to set x 0 and y 240 So as I see x represents left border of vertices. When 240 is y that represents bottom border. Strange. EDIT In canvas i used something like int srcX currentFrame width Rect src new Rect(srcX, 0, srcX width, height) Rect dst new Rect(x, y, x width, y height) canvas.drawBitmap(bitmap, src, dst, null) Where width and height are bitmap.getWidth() bitmap.getHeight() Please, help me to sort it out. Thanks, |
7 | Do Apple and Google ask for a share if custom payment is done in a free app? I have a multiplatform game (web iOS Android) in the making. In the free version the core game is still fully playable but people who choose to pay will get more social features (and no ads, of course). I was thinking that rather than having a free and a paid version for all the platforms I may release the apps just for free and if the users want more, they have to register and pay a one time fee (through a payment gateway or PayPal). The extra content would then be available in all the clients they have access to. Theoretically, this means a better value for the players and less maintenance and headache for me (obviously I have to handle all the payment troubles myself). Does it fit into the business model of Apple Google? Or will they still claim their share of the registration fee? |
7 | OpenGL ES respecting alpha for background but not for objects I have a problem with the alpha of my game, maybe it is solved in another post but as I am new in OpenGl and Game developemnt I dont understand most of the vocabulary and cant find a solution. The problem is I have enemies with alpha and coins with alpha that works great, but when an enemy pass through the coin it take seem the background instead of the coin(same with shoots) there is a image explaining it There is the code to draw enemys and coins public void drawEnemy(GL10 gl) gl.glFrontFace(GL10.GL CCW) Front face in counter clockwise orientation gl.glEnable(GL10.GL CULL FACE) Enable cull face gl.glCullFace(GL10.GL BACK) Cull the back face (don't display) gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glVertexPointer(3, GL10.GL FLOAT, 0, vertexBuffer) gl.glEnableClientState(GL10.GL TEXTURE COORD ARRAY) Enable texture coords array (NEW) gl.glTexCoordPointer(3, GL10.GL FLOAT, 0, texBuffer) Define texture coords buffer (NEW) gl.glEnable(GL10.GL BLEND) gl.glBlendFunc(GL10.GL SRC ALPHA, GL10.GL ONE MINUS SRC ALPHA) front switch (type) case 0 gl.glBindTexture(GL10.GL TEXTURE 2D, TextureLoader.textureIDs 0 ) break case 1 gl.glBindTexture(GL10.GL TEXTURE 2D, TextureLoader.naveEnemigaIDs 0 ) break case 2 gl.glBindTexture(GL10.GL TEXTURE 2D, TextureLoader.naveEnemigaIDs2 0 ) break gl.glDrawArrays(GL10.GL TRIANGLE STRIP, 0, 4) gl.glDisableClientState(GL10.GL TEXTURE COORD ARRAY) Disable texture coords array (NEW) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glDisable(GL10.GL CULL FACE) gl.glDisable(GL10.GL BLEND) public void drawCoin(GL10 gl) gl.glFrontFace(GL10.GL CCW) Front face in counter clockwise orientation gl.glEnable(GL10.GL CULL FACE) Enable cull face gl.glCullFace(GL10.GL BACK) Cull the back face (don't display) gl.glEnableClientState(GL10.GL VERTEX ARRAY) gl.glVertexPointer(3, GL10.GL FLOAT, 0, vertexBuffer) gl.glEnableClientState(GL10.GL TEXTURE COORD ARRAY) Enable texture coords array (NEW) gl.glTexCoordPointer(3, GL10.GL FLOAT, 0, texBuffer) Define texture coords buffer (NEW) gl.glEnable(GL10.GL BLEND) gl.glBlendFunc(GL10.GL SRC ALPHA, GL10.GL ONE MINUS SRC ALPHA) front gl.glBindTexture(GL10.GL TEXTURE 2D, TextureLoader.CointextureIDs 0 ) gl.glDrawArrays(GL10.GL TRIANGLE STRIP, 0, 4) gl.glDisableClientState(GL10.GL TEXTURE COORD ARRAY) Disable texture coords array (NEW) gl.glDisableClientState(GL10.GL VERTEX ARRAY) gl.glDisable(GL10.GL CULL FACE) gl.glDisable(GL10.GL BLEND) |
7 | LibGDX cannot save to internal file I want to save the state of the game in a file, so I can read it at the next start. The Problem is, that I get a exception, if I try to save something internal. If I try to save it local all work fine. I save the file as a Json. Bird bird new Bird() bird.setName("Foo") bird.setSkin(new Texture("data foo.png")) bird.save(Gdx.files.internal("bird.json")) The save mthod Json json new Json() file.writeString(json.prettyPrint(this), false) Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException Error writing file bird.json (Internal) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 349) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 335) at com.buschmannmichael.fattybird.core.Bird.save(Bird.java 31) at com.buschmannmichael.fattybird.game.FattyBirdGame.create(FattyBirdGame.java 16) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java 137) at com.badlogic.gdx.backends.lwjgl.LwjglApplication 1.run(LwjglApplication.java 115) Caused by com.badlogic.gdx.utils.GdxRuntimeException Cannot write to an internal file bird.json at com.badlogic.gdx.files.FileHandle.writer(FileHandle.java 315) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java 346) ... 5 more Whats the problem of LibGDX, where I should save the files, so I can run the game on android, desktop and html ? (I tested this method I showed above only on desktop, maybe it works on android but I want a solution for all platforms) Maybe someone can help me ) |
7 | Equivalent of glDrawTexfOES in OpenGL ES 2.0? I have been using the glDrawTexf extension to draw labels in my Android app using OpenGL ES 1.1. But I have now moved to OpenGL ES 2.0 and can't figure out what is the equivalent of this call? I could create triangles to hold the texture and draw it like a regular texture. But the glDrawTexf was very convenient It didn't require any triangles quads to be setup. You could give it screen co ordinates. You could specify cropping parameters to pick smaller areas from a large texture. |
7 | Does my companion app infringe copyrights? I'm making an android app that is supposed to be just a companion app for a board game. Twilight Imperium 4 is the game, and it has a boatload of techs actions cards strategy cards with tons of text on how they work, so the point of the app is to make it easier to look through game effects. It does not intend to be a copy of the game or to replace the gameboard at all. So, given this context, would it be ok to try and sell it on GooglePlay or would this violate copyright in some way? |
7 | Moving sprites using the accelerometer (Android) In my previous game, I was moving my sprite like so float time 10f Number of seconds to pass a pre defined area (using the screen width in this example) float velocity 1f time work out velocity based on above time float realX velocity dt Move the sprite to the left (where dt is previously defined delta) x realX screenWidth convert to screen coordinates so it can be rendered sprite.draw(x, y) Working out the y position in the same way This all works great when using touch controls. In the above example, the sprite will cross the screen in precisely 10 seconds regardless of the device on which it is running. However, the game I'm currently developing uses the accelerometer to move the sprite. (I'm only moving the sprite left right). Currently, what I'm doing is this Override public void onSensorChanged(SensorEvent event) tilt event.values(axis) Once I have the value, I apply it to my sprite movement like this float time 10f Number of seconds to pass a pre defined area (using the screen width in this example) float velocity 1f time work out velocity based on above time float realX (tilt velocity) dt Move the sprite to the left Now using the tilt value x realX screenWidth convert to screen coordinates so it can be rendered Although this does work it gives nice fluid movement of the sprite, when I run it on an old Galaxy Ace, the sprite accelerates way too fast. This changes the feel of the game note I'm talking only about acceleration here, so if I tilt the phone from left to right repeatedly, the sprite is extremely (too) responsive on the Ace, but 'just right' on my 10" tablet). I've tried a couple of other available games and they seem to run pretty consistently across devices. I'm wondering if my code is correct and if so, what can I do to get all devices running more consistently with regards to the accelerometer? Edit Just to clarify what it is I'm asking. I have a sprite in the middle of the screen sitting on a horizontal platform. When the device is tilted to the left, the sprite moves to the left. The rate of movement should be linked to the angle the device is tilted. So, if the device is vertical there should be no movement. If the device is tilted slowly to the left, further and further the sprite should increase in speed also (up to a limit) ie, accelerate. The other (real world) way to think of it is sitting a ball bearing inside a vertical box (the box representing the device) and then simply tilting the box to the left and right. The ball accelerates towards to lowest corner. The sprite should act like a real ball. If it's accelerating towards to left corner, and the box is tilted in the opposite direction, then the sprite should start to decelerate to a stop, and then srart accelerating in the opposite direction. Just as the real world ball bearing would. My Original code achieves this, however, on some devices it's simply too responsive, it will decelerate and accelerate too quickly. And therefore change the 'feel' of the game making it too easy for one thing. So basically when I say the sprite movement feels 'natural' I'm referring to how the ball bearing would act feel in the real world. This is exactly what I'm looking for hope this helps! |
7 | Loading and rendering one large image or many smaller ones I am working on an android game with a top down style view similar to the original GTA's or a scrolling version of Legend of Zelda. I have recently begun designing some prototype levels for the game which vary between a corridor style dungeon similar to diablo or an open area with obstacles similar to Zelda. My question is would it be better to have one large background image and draw it once or a relatively small one (size of or less than the view) and draw it multiple times. My concerns are the memory required to load store a large background image vs the performance boost of only drawing one image. Any input would be appreciated. |
7 | 3 Button Multi touch for Android OK, my multi touch system was somewhat convoluted, but was working perfectly OK until I tried to run my game on my Nexus 10 which is running Jellybean. Crashing all over the place! So I removed my whole multi touch routine and am trying to start from scratch and to simplify it. Basically, I have 3 buttons, left, right and jump. Left is left of screen, right is right of screen and jump is in the middle. What I need is when the player presses left and that button held down and then they press right, for the latter touch to override, so the right touch registers and the character moves from left to right. If he then releases one of the buttons the character moves in the direction of the button which remains pressed. Again, same with jump. I can get my character moving left and right with single touch but all day I've been trying to understand multi touch and just can't get it. I don't understand the whole pointer ID's and pointer Indexes and would be really grateful if someone could just explain and give an example of some code which would accomplish what I require. Just 2 buttons would do and I could go from there. Many thanks! edit Here is some really basic code and the results I get from it public boolean onTouchEvent(MotionEvent event) int action event.getAction() amp MotionEvent.ACTION MASK int pointerIndex (event.getAction() amp MotionEvent.ACTION POINTER ID MASK) gt gt MotionEvent.ACTION POINTER ID SHIFT int pointerId event.getPointerId(pointerIndex) Log.v("multitouch","pointer ID " pointerId) Log.v("multitouch","pointer Index " pointerIndex) return true when I press the first finger down, ID and Index are both 0 when I press the second finger down, ID and Index are both 0 if second finger is released and the first one remains, the ID and Index are both 0 However, if the first finger is release and the second one remains then the Index is 0 but the ID is 1 I don't understand how this works and how I can use it to determine which fingers are on the screen at which time and would really be grateful if someone could throw some light on it for me thanks!! |
7 | Optimizing Draw calls in MonoGame Android platformer I am working on a 2D platformer that is in the final stages of optimization. I have a few different devices for testing, and I am trying to get the best possible framerate on the weaker ones. On a Nexus 5 I get a constant 60fps, with an occasional hiccup. On a Galaxy S4 I also get a good 55 60fps On an original Galaxy S (Vibrant) The frames drop to about 20 25 My question is, given the tile system described below, what can I do to increase the FPS on low end devices? And granted the Galaxy S came out years ago, should I even worry about it? My background consists of 3 scrolling parallax layers. The world I am drawing in a viewport of 25x15 tiles, at a size of 32x32px per tile, with 3 layers each (32x32x3px). The camera already culls tiles that are out of view. All tiles are found in one texture, and this is done in a single SpriteBatch call that locates the correct texture location for the tile layer. Code is below public void Draw(SpriteBatch spriteBatch, bool upsideDown) int startX GetCellAtPixelX( (int)Camera.Position.X ) int startY GetCellAtPixelY( (int)Camera.Position.Y ) int endX GetCellAtPixelX( (int)Camera.Position.X Camera.ViewportWidth ) int endY GetCellAtPixelY( (int)Camera.Position.Y Camera.ViewportHeight ) for (int x startX x lt endX x ) for (int y startY y lt endY y ) for (int z 0 z lt MapLayers z ) if ((x gt 0) amp amp (y gt 0) amp amp (x lt MapWidth) amp amp (y lt MapHeight)) ... The very last parameter in this draw call is the draw depth. This draw format will arrange layers from front to back (0 front, 1 back) so we subtract 1 from the z index as a decimal to get the appropriate location Background gt 0.7 Middleground gt 0.6 Foreground gt 0.5 spriteBatch.Draw( tileSheet, CellScreenRectangle(x, y), TileSourceRectangle(mapCells x,y . GetLayerIndex((TileLayers)z)), Color.White, 0.0f, Vector2.Zero, effect, 0.7f ((float)z 0.1f) ) End y loop End x loop As you can see, it's not very complex code. I have checked if my Update calls are slowing the game down, but it's very clearly in the Draw function. When I leave out my call to world.Draw(), fps shoot up to about 50 on the Galaxy S. Also, if I draw only a single layer, I get better performance around 42 45 fps. I can discard one layer if necessary, but I need at least 2 tile layers. How else can I speed up the draw calls? I am using MonoGame for Android (XNA) |
7 | How i can control button input android? i am android programmer and i want control button input in android for example i made a game that when you press back button in android mobile nothing happens but i want quite from game. This is how you can use the android back button in Unity games. In C void Update() if (Application.platform RuntimePlatform.Android) if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit() or in JS function Update() if (Application.platform RuntimePlatform.Android) if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit() but how i can contorl other buttons |
7 | Can I include PCM audio data in a commercial application? For certain reasons, I need raw audio data in my application. I would convert certain sounds to a PCM format (at development time), and store amp load these PCM files in my game. PCM stands for Pulse Code Modulation, and as far as I can see, it is a representation of signal, and thus cannot be patented by anyone. Only formats can be patented I suppose (e.g. WAV, which relies on PCM), but PCM sequence of bits cannot be. So if I include PCM data in my application package, I don't violate any patent, do I? I'm developing for Android, by the way. |
7 | Android OpenGL ES RENDERMODE WHEN DIRTY implementation I am trying to understand RENDERMODE WHEN DIRTY so that I could save battery life wherever possible.. I made this sample application so that GlSurfaceView is updated with random color only when the random number temp is greater than 50... If the value of temp is less than 50, I want it to retain the last random color.. But in this code sample, it is not retaining it but making the screen go black forever! Basically I want to know if my implementation of RENDERMODE WHEN DIRTY correct... package com.blob.blob import java.util.Random import javax.microedition.khronos.egl.EGLConfig import javax.microedition.khronos.opengles.GL10 import android.app.Activity import android.opengl.GLSurfaceView import android.opengl.GLSurfaceView.Renderer import android.os.Bundle import android.util.Log public class OpenGLActivity extends Activity implements Renderer GLSurfaceView glView Random rand Override public void onCreate(Bundle s) super.onCreate(s) glView new GLSurfaceView(this) glView.setRenderer(this) glView.setRenderMode(GLSurfaceView.RENDERMODE WHEN DIRTY) rand new Random() setContentView(glView) public void onDrawFrame(GL10 gl) int temp rand.nextInt(100) if(temp gt 50) glView.requestRender() gl.glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1) gl.glClear(GL10.GL COLOR BUFFER BIT) public void onSurfaceChanged(GL10 gl, int width, int height) Log.d("OpenglTest", "Surface Changed") public void onSurfaceCreated(GL10 gl, EGLConfig config) Log.d("OpenglTest", "Surface Created") public void onPause() super.onPause() glView.onPause() public void onResume() super.onResume() glView.onResume() |
7 | LibGDX Swipe Detection Left and Right I have displayed an image at the center of the screen with libgdx. If I swipe left, the image should move to the left and, if I swipe right, image should move to the right. Subsequent swipes to the left should move the image left. The same should happen for right. I used GestureListener. It works to some extent in the sense if I swipe left first image moves left. But after that if I try to swipe right the image still moves left. So how do I implement the expected behavior? class MyGestureListener implements GestureListener Override public boolean fling(float velocityX, float velocityY, int button) if (velocityX gt 0) iX 20 else iX 20 System.out.println("iX " iX) return true ... Gdx.input.setInputProcessor(new GestureDetector(0.0f, 0.0f, 0.0f, 5f, new MyGestureListener())) ... batch.draw(splashTexture, iX, iY) |
7 | Image Buttons Have Low Resolution Quality I'm using Synfig Animator to draw my animations for my android game I'm also using Android Studio to write the code for it, However. On testing, the images that i'm using looks very bad and unfocused even though i made them on a high resolution, I've tried to change the resolution of it but it didn't work! and when i change the size it just get bigger and stay the same.. How can i fix this problem? i need to have perfect animations for my game. |
7 | AndEngine Sprite position I had noticed the AndEngine a few days ago, and I tried to create basic game with a few Sprites.Sure, the engine makes the development process much more easier.However I found the sprite lacking a major functionally Whenever there is a need to refer to the position of an Sprite the engine manipulates the position based on the top left corner of sprite,this is not the best thing because there is a need to subtract add the width height to its position in order to refer to its center.However when we refer to he scale of the Sprite it scaled according to its center point (which is great) I find it very confusing to refer to its position each time differently.I solved that by extending the Sprite class and implementing my methods of setCenter and getCenter, I guess that not the best way to do so. Do you have any suggestion? |
7 | Is there a way to determine Android physical screen size? We're currently porting our games to Android, and would like to be able to release a universal build for tablets and phones. Is there a way to determine the actual screen size or DPI in order to adjust the size of interface elements accordingly? It took a fair bit of research. Here's what we have tried using UnityEngine public class DisplayMetricsAndroid The logical density of the display public static float Density get protected set The screen density expressed as dots per inch public static int DensityDPI get protected set The absolute height of the display in pixels public static int HeightPixels get protected set The absolute width of the display in pixels public static int WidthPixels get protected set A scaling factor for fonts displayed on the display public static float ScaledDensity get protected set The exact physical pixels per inch of the screen in the X dimension public static float XDPI get protected set The exact physical pixels per inch of the screen in the Y dimension public static float YDPI get protected set static DisplayMetricsAndroid() Early out if we're not on an Android device if (Application.platform ! RuntimePlatform.Android) return The following is equivalent to this Java code metricsInstance new DisplayMetrics() UnityPlayer.currentActivity.getWindowManager().getDefaultDisplay().getMetrics(metricsInstance) ... which is pretty much equivalent to the code on this page http developer.android.com reference android util DisplayMetrics.html using ( AndroidJavaClass unityPlayerClass new AndroidJavaClass("com.unity3d.player.UnityPlayer"), metricsClass new AndroidJavaClass("android.util.DisplayMetrics") ) using ( AndroidJavaObject metricsInstance new AndroidJavaObject("android.util.DisplayMetrics"), activityInstance unityPlayerClass.GetStatic lt AndroidJavaObject gt ("currentActivity"), windowManagerInstance activityInstance.Call lt AndroidJavaObject gt ("getWindowManager"), displayInstance windowManagerInstance.Call lt AndroidJavaObject gt ("getDefaultDisplay") ) displayInstance.Call("getMetrics", metricsInstance) Density metricsInstance.Get lt float gt ("density") DensityDPI metricsInstance.Get lt int gt ("densityDpi") HeightPixels metricsInstance.Get lt int gt ("heightPixels") WidthPixels metricsInstance.Get lt int gt ("widthPixels") ScaledDensity metricsInstance.Get lt float gt ("scaledDensity") XDPI metricsInstance.Get lt float gt ("xdpi") YDPI metricsInstance.Get lt float gt ("ydpi") |
7 | LibGDX with SoundPool I'm developing a game for Android using LibGDX in Android Studio. I recently found out that some sounds in my game fail to play. I noticed that every time a sound fails to play, these are the logs 04 12 10 49 51.784 24234 24283 com.gadarts.parashoot.android E AudioTrack AudioFlinger could not create track, status 12 04 12 10 49 51.785 24234 24283 com.gadarts.parashoot.android E SoundPool Error creating AudioTrack 04 12 10 49 52.503 24234 24283 com.gadarts.parashoot.android W AudioTrack AUDIO OUTPUT FLAG FAST denied by client transfer 4, track 44100 Hz, output 48000 Hz This is the code I use to play the sounds public long playSound(SFX fileName, boolean loop, float volume, boolean randomPitch) if (GameSettings.SOUND TOGGLE) try Sound sound prepareSound(fileName) if (randomPitch amp amp GameSettings.SOUND RANDOM PITCH) return setRandomPitch(loop, sound, volume) if (loop) return sound.loop(volume) else return sound.play(volume) catch (GdxRuntimeException e) e.printStackTrace() return 1 private Sound prepareSound(SFX soundFile) throws GdxRuntimeException try String soundPath SFX.fileAttribute.SFX FOLDER NAME.getValue() " " SFX.fileAttribute.SOUNDS FOLDER NAME.getValue() " " soundFile.getParentDir().getValue() " " soundFile.getValue() "." soundFile.getFormat().getValue() Sound sound if (!sounds.containsKey(soundFile.getValue())) sound Main.getAssetsManager().get(soundPath, Sound.class) sounds.put(soundFile.getValue(), sound) else sound sounds.get(soundFile.getValue()) if (sound null) throw new GdxRuntimeException("preparing sound failed sound not found.") return sound catch (GdxRuntimeException e) throw e The sound files are in WAV format. Any ideas how to fix it? Thanks in advance! Update I've found out that this problem appears only on my Nexus 5X. I tried it on Xiaomi Redmi Note 4X and it didn't happen. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.