my problem is, like described in the Title, that i can not integrate an own BitmapFont into my libGDX skin. I searched a lot and there are many Topics with exact my problem, but their solution never work for me. Here is my code:
skin = new Skin();
skin.add("default-font", StaticValues.generateFont(40, Color.BLACK), BitmapFont.class);
FileHandle fileHandle = Gdx.files.internal("scene2d.ui/uiskin.json");
FileHandle atlasFile = fileHandle.sibling("scene2d.ui/uiskin.atlas");
if (atlasFile.exists()) {
skin.addRegions(new TextureAtlas(atlasFile));
}
skin.load(fileHandle);
and now they say that i should remove this line:
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: default.fnt } },
out of my JSON-File. But then this error occurs:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: scene2d.ui/uiskin.json
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:98)
...
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: white
is there a simple solution for my problem?
Thanks in advance
Edit:
i already tried one other thing:
Other Solution, not working for me
Related
I have been working in flash again! Back working on games again... this time a choose your path game, and it needs to save. To do this I've got a few classes going, and had quite a few errors... Then I ran into this error for seemingly no reason... It clams is in this section,
public class MenuScreen extends MovieClip {
static function checkData()
public function MenuScreen() {
}
static function checkData()
SharedObject.getLocal(userData:string);
// Create a shared-object named "userData"
mySharedObject=SharedObject.getLocal("userData");
More precisely this line:
SharedObject.getLocal(userData:string);
Now theres a bit of code at the top I left off yes, And I can provide the entire code if it will help, But correct me if Im wrong the program isn't making sense! This has happened before, The solution being to completely redo the file, Retype the code, (NOT copy/paste) and Don't allow so many test exports to fail! So I know I've experienced this error as a misstate before. Is it a misstate this time? Thats why Im here... ...
Your code does not looks like an AS3 class and that's not that obvious how it was supposed to look like. At least I can provide you fix with will compile:
class MenuScreen extends MovieClip
{
public function MenuScreen()
{
}
public static function checkData():void
{
// Create a shared-object named "userData"
mySharedObject=SharedObject.getLocal("userData");
}
}
But note that function checkData() is not called.
While learning a bit of libGDX by creating my mini project i decided that i need text input, created text field, a skin for it, but errors occurs with importing default skin.
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:
com.badlogic.gdx.utils.SerializationException: Error reading file: data/uiskin.json
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: data/uiskin.json
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:72)
at com.me.bpmtest.BpmTest.create(BpmTest.java:47)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:127)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: data/uiskin.json
at com.badlogic.gdx.utils.Json.fromJson(Json.java:613)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:93)
... 4 more
Caused by: com.badlogic.gdx.utils.SerializationException: Field not found: scrollStyle (com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle)
at com.badlogic.gdx.utils.Json.readFields(Json.java:703)
at com.badlogic.gdx.utils.Json.readValue(Json.java:816)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:409)
at com.badlogic.gdx.utils.Json.readValue(Json.java:766)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.readNamedObjects(Skin.java:434)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:422)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:415)
at com.badlogic.gdx.utils.Json.readValue(Json.java:791)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:409)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:611)
... 5 more
I use default skin files from here
Here's code snippet of my create function:
public void create() {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
//Gdx.input.setOnscreenKeyboardVisible(true); - for android later.
AndroidInput listener = new AndroidInput();
stage = new Stage();
textfield = new TextField("", skin);
textfield.setMessageText("Enter Push number");
....
}
I'm really just a beginner here, maybe there is simpler way to get text input? I need to get integer from a user.
Check the tools box on the libgdx launch screen. Then you will have all the default files that are used in many libgdx examples including uiskin.json. After you do that you can just call Gdx.files.internal("uiskin.json")
So I upgraded to the latest nightly and updated my project to remove all calls to GL10 but I am getting this error even though I have removed the reference to it.
Exception in thread "main" java.lang.NoSuchFieldError: useGL20
at com.me.mygdxgame.Main.main(Main.java:10)
This is what the code in the file looks like
package com.me.mygdxgame;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
public class Main {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-gdx-game";
// cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new MyGdxGame(), cfg);
}
}
Does anyone have an idea of why I still keep getting this error?
The latest libgdx build has gotten rid of the opengl 1.0 backend so the field cfg.useGL20 is no longer needed. If interested read up here
According to that page
LwjglApplicationConfiguration and AndroidApplicationConfiguration do not have the useGL20 flags anymore.
So eliminate that line and things should be good if you updated each project to the newest nightely. If you are still having problems update projects again to the newest nightly as this is very new to libgdx so there are probably a lot of bugs
I am upgraiding a loader for external flash game(this loader is already written and it is working, but I have been using previous version of Flash Builder(not sdk!) to write it.
What I need is to see what classes of my code does not exist in the project... For now it just compiles everything with or without errors and does not shows any errors or warnings to me.
I think the example will show what I mean:
I have a working function wich compiles without errors:
protected function init(event:Event = null) : void
{
Living.movie.removeEventListener(Event.ADDED_TO_STAGE, this.init);
this.GamePlayer = Living.movie.parent.parent;
this.Map = this.GamePlayer.map;
this.Map.addEventListener(Event.REMOVED_FROM_STAGE, this.dispose);
}
I am making changes to this function:
protected function init(event:Event = null) : void
{
NotExistingClassOrVariable = OMGIT will compile and so on;
Living.movie.removeEventListener(Event.ADDED_TO_STAGE, this.init);
this.GamePlayer = Living.movie.parent.parent;
this.Map = this.GamePlayer.map;
this.Map.addEventListener(Event.REMOVED_FROM_STAGE, this.dispose);
}
and above function compiles without any errors too.... I can write anything inside a function body - it will compile(but it will not work ofcaurse)...
Please help me to solve this problem - trying to solve it already for 8 hours.
And sorry for my really bad english =(
Solved a problem by reinstalling flash builder. I do not know why it happened, but seem it was IDE bug.
For some reason, when I try to receive a shared property from a Worker (in AS3), the result is always null. That is, I send a value to a Worker using setSharedProperty(), when I retrieve it using getSharedProperty(), it always returns undefined/null.
Here's a simple test I set up:
package
{
import flash.display.Sprite;
import flash.system.Worker;
import flash.system.WorkerDomain;
public class Main extends Sprite
{
private var _worker:Worker;
public function Main():void
{
if (Worker.current.isPrimordial)
{
initMain();
}
else
{
initWorker();
}
}
private function initMain():void
{
_worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
_worker.setSharedProperty("message", "test");
_worker.start();
}
private function initWorker():void
{
_worker = Worker.current;
var message:String = _worker.getSharedProperty("message");
trace(message);
}
}
}
When I trace message, the result is null. Although my main goal is to make an AIR app, I get the same result whether I'm compiling for AIR (3.7) or Flash Player (11.6, for some reason 11.7 doesn't recognise flash.system.Worker as a valid class).
I'm compiling using the Flex SDK, through FlashDevelop. Does anybody know what's wrong, maybe I've missed something in my code?
FlashDevelop now seems to have complete support for debugging workers which really wasn't the case on older versions (you could neither break, or trace inside workers). AIR SDK workers support has also progressed (I remember things working in release would break in debug version)
I just recompiled your sample with AIR SDK 14 release (14.0.0.110)
air14_sdk_win/bin/mxmlc -swf-version=25 -debug=true Main.as
and debugged it with Shockwave Flash Debugger 14,0,0,125 and FlashDevelop 4.6.1.30 and got the expected result:
[Starting debug session with FDB]
Created Worker 2
test
Beware that any element not up-to-date in your debugging chain (sdk/player/debugger) could result in problems for debugging workers