wreed12345
|
 |
«
Posted
2012-12-29 20:22:28 » |
|
I have never used this engine or any multiple platform engine, So I am just curious If i wrote a code that changed the game screen when i clicked in a certain area on the game (on computer version) would I have to write something different to get this to work on an android version of the app? I have never used an engine really before so I am not sure about this. And where would a good place to learn libgdx be?
|
|
|
|
davedes
|
 |
«
Reply #1 - Posted
2012-12-29 20:27:31 » |
|
Things like screen size (small Android devices vs desktop monitors), input (finger touch vs. mouse and keyboard), data storage (class-path on desktop/Android vs not on HTML) and so forth will obviously need to be taken into consideration. With that said, most of your code should be application independent, as long as you are being smart about things. (For example, instead of using absolute UI positions and sizes which won't work on multiple resolutions, you might use layouts and resizable content.) But if you are new to programming and gamedev, then I would suggest learning by writing several games for a single platform (e.g. desktop) before you try writing a multi-platform game. Plenty of resources on LibGDX if you google it: http://libgdx.badlogicgames.com/documentation.html
|
|
|
|
matheus23
|
 |
«
Reply #2 - Posted
2012-12-29 20:29:14 » |
|
In comparison, I'd say that libgdx is the only possible solution for having 99% of your code being able to be executed on all platforms: PC, Android, iOS (unsure) and html5.
If you do it right, of course.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
wreed12345
|
 |
«
Reply #3 - Posted
2012-12-29 20:29:24 » |
|
Thanks for the advice but im not that new to java or gamedev I have made a pc and android game before. And im not sure if your aware but libgdx supports multiple platforms so I wasnt sure if I was the one who had to do this porting or libgdx offered some help
|
|
|
|
|
Phibedy
|
 |
«
Reply #5 - Posted
2012-12-29 23:19:54 » |
|
I started gamedev with java2d, why? All tuts are about java2d. After that I tried myself at jogl, I soon realized that most of the tuts are deprecated, that's why I switched to lwjgl. With some help of the forum I got familiar with it, the community is absolutely noobfriendly  Now I am using libgdx for android, it's really worth it. If you use libgdx u get access to some really beginnerfriendly functions. The filesystem/rendering is completely platform independent. Furthermore I enjoy box2d, the "physics engine" I wrote by my self wasn't that accurate. Lastly I don't like the android sdk that much, I prefere libgdx  best regards
|
|
|
|
wreed12345
|
 |
«
Reply #6 - Posted
2012-12-30 00:58:58 » |
|
how did u learn libgdx? i really want to start using it but im not sure how. this wont be my first game, i haev coded my own android game and made a pc game using slick2d and another pc without an engine. so im not too much of a newb lol
|
|
|
|
wreed12345
|
 |
«
Reply #7 - Posted
2012-12-30 01:01:44 » |
|
I know some of you might say google this, but im curious of what you guys have used to learn using libgdx for android and what has and hasnt been sucessful for you
|
|
|
|
pitbuller
|
 |
«
Reply #8 - Posted
2012-12-30 02:04:08 » |
|
I know some of you might say google this, but im curious of what you guys have used to learn using libgdx for android and what has and hasnt been sucessful for you
This is quite good http://code.google.com/p/libgdx/wiki/SimpleAppOther parts of the wiki was also quite helpfull. Google is king after that.
|
|
|
|
ReBirth
|
 |
«
Reply #9 - Posted
2012-12-30 02:08:11 » |
|
Try and error by myself, and hit google (mostly user wiki) when something wrong.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
|
wreed12345
|
 |
«
Reply #11 - Posted
2012-12-30 04:37:13 » |
|
Thanks alot guys I really appreciate this. !
|
|
|
|
Phibedy
|
 |
«
Reply #12 - Posted
2012-12-30 11:31:49 » |
|
Most of the time I google my errors, but there are a lot of deprecated, outdated, "you shouldn't programm like that", let them call "tutorials" out there. After I can't find any good solution I post it in the newbie-section -> There's always a good guy/woman(haven't recognised one jet but don't want to discriminate them), who likes to help me  There's a leack of good up-to-date java tuts. 1. That's my favorite: http://code.google.com/p/libgdx/wiki/SimpleApp2. Of course the api is quite helpfull: http://libgdx.badlogicgames.com/nightlies/docs/api/3. That's about box2d: http://www.iforce2d.net/b2dtut/forces (it's in C++ but you will get it) 4. The java-gaming.org community  best regards
|
|
|
|
Danny02
|
 |
«
Reply #13 - Posted
2012-12-30 12:41:35 » |
|
quick question about libgdx cross-compilation, is there are blog post or wiki page which lists all the things one must think of when cross-compiling to another platform.
Like what classes are forbidden to use and how to use libraries and so on.
|
|
|
|
Cero
|
 |
«
Reply #14 - Posted
2012-12-30 15:45:39 » |
|
quick question about libgdx cross-compilation, is there are blog post or wiki page which lists all the things one must think of when cross-compiling to another platform.
Like what classes are forbidden to use and how to use libraries and so on.
not that I know of, generally you really have only a few things to think about. IF you want to do direct opengl calls, I think it is best to use "Gdx.graphics.getGLCommon()" instead of "Gdx.graphics.getGL10()" for example - I THINK. ehm... in applet you cannot use FileHandle.list() - for obvious reasons. However I made this mistake a couple of times, since I would have a folder and load everything in it... I cant really think of anything else... the HTML 5 port has some more stuff you cannot use, like System.nanoTime(), but upon convert/compiling it will tell you when a line cannot be used.
|
|
|
|
wreed12345
|
 |
«
Reply #15 - Posted
2012-12-30 16:35:23 » |
|
since I have not learned opengl yet would it be beneficial to me to do so before using libgdx?
|
|
|
|
Jimmt
|
 |
«
Reply #16 - Posted
2012-12-30 16:37:48 » |
|
Not necessarily, you can always call opengl commands through libGDX anyways, and the learning curve of opengl might be too steep.
|
|
|
|
davedes
|
 |
«
Reply #17 - Posted
2012-12-30 16:50:35 » |
|
IF you want to do direct opengl calls, I think it is best to use "Gdx.graphics.getGLCommon()" instead of "Gdx.graphics.getGL10()" for example - I THINK. It works like tihs: If your app uses GL20 (e.g. it was specified in application config or is required by the platform you're distributing to) then Gdx.gl20 will be non-null, and Gdx.gl10 will be null. For apps that don't have "useGL20=true", then Gdx.gl20 will be null, and Gdx.gl10 will be non-null. Gdx.gl (or Gdx.graphics.getGLCommon) should never return null. For example, the following is standard practice: 1 2 3 4 5
| if (Gdx.graphics.isGL20Available()) { Gdx.gl20.glXXX } else { Gdx.gl10.glXXX } |
|
|
|
|
matheus23
|
 |
«
Reply #18 - Posted
2012-12-30 17:27:58 » |
|
Side-question @davedes: What if I have a set up, and I want to use ? It wants to have a GL10, but I can't feed him one, if I only have a gl20 available...
|
|
|
|
davedes
|
 |
«
Reply #19 - Posted
2012-12-30 19:55:16 » |
|
"Apply" sets up fixed-function matrices to the specified camera's projection and view matrix: 1 2 3 4 5 6
| public void apply (GL10 gl) { gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(projection.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadMatrixf(view.val, 0); } |
So the equivalent in GL20 would be to send a projection and/or modelview matrix to your shader. Typically it might look like: 1 2 3
| shader.begin(); shader.setUniformMatrix("u_projView", camera.combined); shader.end(); |
If you use SpriteBatch and Stage for 2D rendering, you shouldn't need to call apply() or setUniformMatrix(). 
|
|
|
|
badlogicgames
|
 |
«
Reply #20 - Posted
2012-12-30 19:56:19 » |
|
As per the Javadocs, that method of OrthographicCamera is only applicable in a GLES 1.x environment. With GLES 2.0 you'd submit the camera matrices to your shader.
To ensure your app works across all platforms, try to stick to what libgdx provides. This includes things like file i/o (use Gdx.app.files), networking (Gdx.app.net) and so on. The reason is that Android, HTML5 and iOS do not support all classes in the JRE. That's why we provide replacements which are sometimes even a bit better than their JRE equivalents in terms of say memory consumption and GC friendliness.
In terms of OpenGL ES, you can chose between 1.x (fixed function) or 2.0 (shaders). The higher level classes like SpriteBatch, BitmapFont and so on are all agnostic about which version you use. If you only issue OpenGL ES commands via the GLCommon interface (Gdx.gl) and leave the rest to the higher level classes, you will not run into any issues. If you want more control, you'll have to special case your rendering depending on what's available on the system. The gdx-invaders example in the repo demonstrates this. It has one renderer for OpenGL ES 1.x and another one for 2.0. Again, this is only necessary if you want to get your hands dirty with low-level OpenGL ES yourself.
TL;DR: use what libgdx provides, stay away from JRE classes if you target HTML5.
|
|
|
|
ReBirth
|
 |
«
Reply #21 - Posted
2012-12-31 03:30:22 » |
|
The only JRE class that I use is only Math, just to abs and round >.>
|
|
|
|
namrog84
|
 |
«
Reply #22 - Posted
2012-12-31 06:17:15 » |
|
Also if you go with Libgdx and want to convert to html5, there are certain things you can't do in html5 This is as of no fault of libgdx, but of the google GWT, you can't use certain things for GWT. The most specific example is Reflection. Although its usually half decent to rewrite code to not use it.
|
"Experience is what you get when you did not get what you wanted"
|
|
|
matheus23
|
 |
«
Reply #23 - Posted
2012-12-31 15:57:19 » |
|
"Apply" sets up fixed-function matrices to the specified camera's projection and view matrix: 1 2 3 4 5 6
| public void apply (GL10 gl) { gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(projection.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadMatrixf(view.val, 0); } |
So the equivalent in GL20 would be to send a projection and/or modelview matrix to your shader. Typically it might look like: 1 2 3
| shader.begin(); shader.setUniformMatrix("u_projView", camera.combined); shader.end(); |
If you use SpriteBatch and Stage for 2D rendering, you shouldn't need to call apply() or setUniformMatrix().  Uh oh... okey... I was using , so giving to renderer.render(world, cam.combined); |
was enough. Thanks  more off-topic stuff: Having guys hanging out at #libgdx irc would be pretty cool, since I often have quick questions, but can't get an answer anywhere... And using a forum topic is sometimes too much. (And sometimes I want a really quick answer, instant message is often pretty good). Sorry for posting so much off-topic...
|
|
|
|
Nate
|
 |
«
Reply #24 - Posted
2012-12-31 17:20:30 » |
|
Try #libgdx on FreeNode. Usually some ~60 people in there.
|
|
|
|
matheus23
|
 |
«
Reply #25 - Posted
2012-12-31 17:24:38 » |
|
Try #libgdx on FreeNode. Usually some ~60 people in there.
Wth... I think I have a serious brain damage 
|
|
|
|
|