libgdx

Get Firebase to work with java, not Android

谁都会走 提交于 2019-11-29 10:47:32
Im trying to get a libgdx project up and running and I want to firebase for user logins. I'm finding that the SimleLogin class is depending on Android.jar. Is there a way around this as I would like to have a desktop java application running as well as android. Here is the code that is causing the issue: SimpleLogin authClient = new SimpleLogin(myRef);; authClient.createUser("myuser@gmail.com", "much wow", new SimpleLoginAuthenticatedHandler() { @Override public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) { if (error != null) { System.out.println(error); }

Drawing filled polygon with libgdx

China☆狼群 提交于 2019-11-29 10:28:34
问题 i wanted to draw some (filled) polygons with libgdx for an android game. it shoudn't be filled with a graphic/texture. i have only the vertices of the polygon (closed path) and tried to visualize with meshes but at some point this is not the best solution, i think. my code for an rectangle is: private Mesh mesh; @Override public void create() { if (mesh == null) { mesh = new Mesh(true, 4, 0, new VertexAttribute(Usage.Position, 3, "a_position") ); mesh.setVertices(new float[] { -0.5f, -0.5f, 0

Is there a way to incorporate vector graphics into LibGDX development?

别等时光非礼了梦想. 提交于 2019-11-29 10:04:51
I haven't found anything in LibGDX that would work with vector graphics. This post suggests that AGG is close as it gets, they also mentioned that it is a lot of pain. Is there a painless alternative ? P.T. There does not seem to be any painless support for vector graphics in Libgdx at this point (mid-2013). First, for vector graphics generally that means SVG in practice. Part of the problem with a "generic" SVG solution is that getting it to work with all the various corner cases seems to be an issue. However, if you are just trying to render your own SVG objects, you may have a simpler

Running Java application in Android Studio

假装没事ソ 提交于 2019-11-29 09:47:56
问题 I created new libgdx project and i want to run desktop application in Android Studio. Is there something to do with run configurations? In Eclipse i can just choose Run as Java Application. 回答1: Ok, i did it. Here is the solution https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA#running-your-project Run -> Edit Configurations... , click the plus ( + ) button and select Application. Set the Name to Desktop . Set the field Use classpath of module to desktop , then click on the

how to flip a pixmap to draw to a texture in libgdx?

不想你离开。 提交于 2019-11-29 09:45:24
So what I'm trying to do is to generate a background image for my game by drawing pixmaps to a texture. So far I can do that, but now I need to draw the pixmaps flipped in the X or Y axis to the texture. However I can't find anything to do so. The pixmap class does not provide that functionality. Then I thought I could draw a flipped texture region to a texture, but so far I haven't found how to do so. So I was wondering how can I do such a thing, would it be possible to flip a png image with other java libraries and then create a pixmap from that flipped image? I also don't see other option

Cocos2D OR libgdx for Android Game Development [closed]

删除回忆录丶 提交于 2019-11-29 09:30:50
I just want to know, that in the long run, using which of these engines will be better. Although I feel that using Cocos2D will be a better option, as it can also be used for iphone development, there's just 1 tutorial http://dan.clarke.name/2011/04/how-to-make-a-simple-android-game-with-cocos2d/ which I've found so far. libgdx, on the other hand has a complete book. Jong Consider using AndEngine . From a short look at libgdx, they seem similiar (Although AndEngine is 2D only). However, AndEngine has everything you need for a 2D game. The only thing it lacks is documentation, but it is open

LibGDX重建Flappy Bird——(7) 添加GUI信息

梦想与她 提交于 2019-11-29 09:30:27
本章源码链接: http://pan.baidu.com/s/1hruBkgc 密码:94iq 上一章介绍我们基本已经完成FlappyBird的游戏逻辑,接下来在本章将添加一些GUI信息,如分数、按钮等。 分数GUI 首先我们需要为WorldController维护一个int值表示当前玩家获得的分数。修改WorldController并添加相应的方法: ... public class WorldController extends InputAdapter implements Disposable { ... public int score; ... private void init() { ... score = 0; isStart = false; ... } ... // 计算分数 private void calculateScore () { for(Pipe pipe : pipes.pipes) { if(pipe.position.x < bird.position.x) { if(pipe.getScore() == 1) { score += 1; Gdx.app.debug(TAG, "Your current score:" + score); } } } } public void update(float deltaTime) { ...

LibGDX重建Flappy Bird——(1) 项目创建与导入

血红的双手。 提交于 2019-11-29 09:30:13
为了节省时间和篇幅,有关LibGDX的基础内容在本文将不会介绍。如果有需要可以查看 土豆教程 。 我们在本项目中使用的是旧版libgdx项目生成工具gdx-setup-ui.jar,虽然该工具是旧版,但是对于简单的项目来说该工具还是非常方便的。下面我们将通过该工具创建项目。 首先双击打开该工具,如图所示: 点击创建按钮,并输入相应的项目名称: 其中Name表示项目名称,package表示包名,game class表示游戏主类名称。这里为了方便我们只选中了两个平台的项目:android和desktop。我们发现上述窗口的第二窗格的Required下出现了一行红色的LibGDX字样,这表明我们还没有选中要使用的LibGDX源压缩文件。下面步骤我们将解决该错误。 点击 按钮,弹出文件选择对话框,如下所示: 选中libgdx-1.2.0.zip文件并点击打开按钮。 然后我们发现LibGDX字样变为绿色了,这表明现在已经准备完毕我们可以生成项目了: 点击 按钮弹出下面窗口: 点击Launch!按钮,稍等一会,发现窗口显示All done!字样表明项目创建成功。 关闭LibGDX Project Setup工具,开始导入项目。 接下来,我们开始导入项目,对于旧版工具生成的项目导入方法非常 简单。首先打开Eclipse,选择File->improt弹出下面导入对话框: 选择General-

LibGDX重建Flappy Bird——(5) 添加Box2D物理仿真和游戏逻辑

核能气质少年 提交于 2019-11-29 09:30:06
本章源码链接: http://pan.baidu.com/s/1o6Tt6VS 密码:dvsc 在本章我们将为Flappy Bird添加BOX2D物理仿真,BOX2D物理仿真可以模拟现实世界物体的属性,如重力、速度、摩擦等等。在BOX2D中存在三种物理对象,分别是StaticBody、KinematicBody和DynamicBody,其中静态物体StaticBody只能模拟那些固定不动的对象且不能与StaticBody和KinematicBody类型物理对象发生碰撞。KinematicBody和StaticBody类似,但是他可以模拟速度,让对象按照一定的速度运动,但他也不能与StaticBody和KinematicBody类型物理对象放生碰撞。最后一种DynamicBody对象既可以模拟所有物理属性,也可以与上述三种类型物体的任意一种发生碰撞。 首先,我们为三个对象添加一个共同的方法,既然是共同的方法,那么我们就应该添加到三者公用的父类中,然后再子类中重写该方法。 修改AbstractGameObject: package com.art.zok.flappybird.game.object; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils;

LibGDX重建Flappy Bird——(8)屏幕切换与播放声音(终结)

本秂侑毒 提交于 2019-11-29 09:30:05
本章源码链接: http://pan.baidu.com/s/1sjYE0sH 密码:q4n2 正如标题上所标注的,本章将完成FlappyBird的所有剩余内容。对比原版游戏我们可以发现FlappyBird现在还差两个界面,如下所示: LibGDX提供Game和Screen两个类使我们可以将游戏拆分为多个界面。其中Game实现了ApplicationListener接口,所以他也可以作为项目的主类(也就是共享项目的启动类)。而Screen是LibGDX提供的一个具有完整生命周期的界面类。Game类提供了一个setScreen()方法可以让我们切换界面。 现在我们将游戏拆分为三个界面,分别是欢迎界面(WelcomeScreen)、预览界面(PreviewScreen),这两个界面分别对应上述两张截图,最后一个界面就是我们的游戏开始界面(FlappyBirdScreen)。那么游戏主类就是继承于Game的一个类了,这里我们命名为FlappyBirdGame。 在欢迎界面我们有两个目的,第一个目的是显示一个具有标志性的logo,第二个目的是加载资源。这两个目的是相辅相成的,我们知道,当资源过多时从硬盘加载到内存是需要相当大的开销,如果我们直接加载的话,屏幕可以能会出现短暂的黑屏甚至可能导致ANR(应用程序无响应),这样的情况对于用户来说是一种极为糟糕的体验