Libgdx gl10.glLineWidth()

From libgdx 1.0 on there is also the ShapeRenderer’s rectLine method available. See a simple example. ShapeRenderer shapeRenderer = new ShapeRenderer(); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rectLine(x1, y1, x2, y2, width); shapeRenderer.end(); That seems to be the easiest way to draw thick lines now.

“Tainted canvases may not be loaded” Cross domain issue with WebGL textures

are you setting the crossOrigin attribute on your img before requesting it? var img = new Image(); img.crossOrigin = “anonymous”; img.src = “https://graph.facebook.com/1387819034852828/picture?width=150&height=150”; It’s was working for me when this question was asked. Unfortunately the URL above no longer points to anything so I’ve changed it in the example below var img = new Image(); … Read more

Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

I had the issue when I put jcenter() before google() in project level build.gradle. When I changed the order and put google() before jcenter() in build.gradle the problem disappeared Here is my final build.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } … Read more

How get a string width in Libgdx?

BitmapFont API < 1.5.6 To mesure the width of a String you use your Font and get the bounds of the String, you are going to draw. BitmapFont.getBounds(String str).width BitmapFont API You can get the height to for the right offset for drawing too. Just replace width with height. In addition for multiline texts use … Read more

How to draw smooth text in libgdx?

font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); This gets the texture used in a BitmapFont and changes its filtering to bilinear, allowing higher resulting image quality while both up- and downscaling it at the cost of slightly slower (the difference is usually not noticeable) GPU rendering.

Default Skin LibGDX?

When it comes to UI in libGDX, you will find its very different than what you would have used before (yaml, json, xml, UI Builders, etc). Table Layout – This is how Scene2d UI is structured and formatted. The link you have provided is a great tutorial, but as you have come to realize, you … Read more

Adding Admob to libgdx

Add AdMob Ads without Firebase : Put these lines inside build.gradle of android module. dependencies { compile ‘com.google.android.gms:play-services-ads:10.2.4’ } Add permission in AndoidManifest.xml file <uses-permission android:name=”android.permission.INTERNET”/> <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /> Inside <application tag add Activity if want to use Interstitial Ads <meta-data android:name=”com.google.android.gms.version” android:value=”@integer/google_play_services_version” /> <activity android:name=”com.google.android.gms.ads.AdActivity” android:configChanges=”keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize” android:theme=”@android:style/Theme.Translucent” /> AndroidLauncher class. public class AndroidLauncher extends … Read more

“File not found” when running new LibGDX project

From libgdx wiki When you run Desktop Project The application will fail the first time. Open the Run Configuration you just created and set the working directory to the android/assets/ directory! link your desktop project to android assets folder? Go to Run => Run Configurations.. => choose DesktopLauncher, Arguments Tab => Working Directory => Others … Read more