PhaserEditor2D / PhaserEditor

A friendly IDE to develop HTML5 games based on the Phaser framework.
https://phasereditor2d.com
Eclipse Public License 1.0
330 stars 45 forks source link

Cannot add texture Atlas to Asset Pack file. #54

Closed oskfan closed 6 years ago

oskfan commented 6 years ago

Selecting the Atlas alternative on "Add Asset" does nothing.

Manually adding an Atlas to the .json file adds it to the Asset Pack but it doesn't work adding another via the editor interface. Browse button doesn't work either for the atlasURL.

All other options seem to work just fine.

Current editor version is v1.4.2 running the included Phaser version v2.6.2

PhaserEditor2D commented 6 years ago

Hi @oskarfantasma, I need more details. Can you paste here a screenshot?

By the way, did you create the atlas files with Phaser Editor or another tool?

oskfan commented 6 years ago

Hi!

The atlas was created in another program, but that doesn't matter since the PACK itself doesn't allow creating a atlas asset. These screenshots show creating image assets is no problem. However trying to add an atlas does nothing.

On Mon, Oct 2, 2017 at 2:10 PM, Arian Fornaris notifications@github.com wrote:

Hi @oskarfantasma https://github.com/oskarfantasma, I need more details. Can you paste here a screenshot?

By the way, did you create the atlas files with Phaser Editor or another tool?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/boniatillo-com/PhaserEditor/issues/54#issuecomment-333515907, or mute the thread https://github.com/notifications/unsubscribe-auth/AeaTEgzQcMwlFvnd4WsDF3Fz6xMqoZWTks5soNLBgaJpZM4Pqa07 .

PhaserEditor2D commented 6 years ago

Hi, where are the screenshots?

oskfan commented 6 years ago

phaser_editor_6 phaser_editor_5 phaser_editor_4 phaser_editor_3 phaser_editor_2 phaser_editor_1

PhaserEditor2D commented 6 years ago

Yes, it looks like it had an internal error. Please, can you open the Error Log view and check if an error is added?

To open the Error Log view press Ctrl+3 and type Error Log.

PhaserEditor2D commented 6 years ago

By the way, the best is if you can attach here (or send me via email) the texture image and json file.

oskfan commented 6 years ago

It's a: "Unhandled event loop exception" This is the error log for clicking the atlas button. I won't bother sending the texture image and json file since they are not part of the problem. The problem is creating an atlas asset in any arbitrary Asset Pack.

!ENTRY org.eclipse.ui 4 0 2017-10-03 16:39:50.584 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.RuntimeException: java.lang.NullPointerException at phasereditor.assetpack.ui.editors.AssetPackEditor.openNewAssetDialog(AssetPackEditor.java:598) at phasereditor.assetpack.ui.editors.AssetPackEditor$4.widgetSelected(AssetPackEditor.java:364) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151) at phasereditor.ide.intro.PhaserIDE2.start(PhaserIDE2.java:42) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) at org.eclipse.equinox.launcher.Main.run(Main.java:1499) Caused by: java.lang.NullPointerException at phasereditor.atlas.core.AtlasCore.getAtlasFormat(AtlasCore.java:121) at phasereditor.assetpack.core.AssetPackCore$2.apply(AssetPackCore.java:289) at phasereditor.assetpack.core.AssetPackCore$2.apply(AssetPackCore.java:1) at phasereditor.assetpack.core.AssetPackCore$3.visit(AssetPackCore.java:327) at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:120) at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:84) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87) at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:129) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:52) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105) at phasereditor.assetpack.core.AssetPackCore.discoverFiles(AssetPackCore.java:313) at phasereditor.assetpack.core.AssetPackCore.discoverAtlasFiles(AssetPackCore.java:283) at phasereditor.assetpack.core.AssetPackModel.discoverAtlasFiles(AssetPackModel.java:246) at phasereditor.assetpack.core.AssetFactory$9.createAsset(AssetFactory.java:210) at phasereditor.assetpack.ui.editors.AssetPackEditor.openNewAssetDialog(AssetPackEditor.java:590) ... 29 more

PhaserEditor2D commented 6 years ago

Please can you tell me the format you used to pack the atlas? Is it JSON? did you exported it with Texture Packer? I need more details, maybe you can use another format while we fix this issue.

oskfan commented 6 years ago

Its a JSON yes, so I can just manually write a standard Phaser atlasJson loading line for it in the relevant file so thats not a problem. I can wait for the fix and use that until it's done. :)

PhaserEditor2D commented 6 years ago

The problem is that if you load it outside the pack.json file you cannot use it in the scene.

Yet I can't fix the bug because I cannot reproduce it.

oskfan commented 6 years ago

That's weird, so you can actually create a new asset pack and add an atlas asset to it?

PhaserEditor2D commented 6 years ago

Yes sure!!! That feature is there from the first version of the editor!!! For that reason, I need if possible you send me the atlas you are trying to add, so I can see what's the problem. If you are worried about the content of the image you can blur it, I just need to test the JSON file.

oskfan commented 6 years ago

So I kinda figured out what the cause was. I don't understand why it didn't work though. Creating an atlas asset in the atlas pack in a fresh Phaser Game project was working fine. But not in the project i wanted to. Even moving or copying the working asset pack to the other project caused it to stop allowing new atlas assets to be added.

So. In the base "/WebContent/" folder: In my "/src/" folder (to which i save my .js files) i had a ".svn" folder for Subversion Control. And in my "/lib/" folder i had a subfolder with "/node_modules/" and a plugin.

Removing the .svn folder and the node_modules folder allowed me to create a atlas asset in that project as well. So I'm guessing that the problem is related to how it creates the Atlas assets in the Asset Packs. Probably when parsing the files and folder structure.

oskfan commented 6 years ago

In a third project I didn't have the .svn folder anywhere in my project structure but I did have a node_modules folder with @types for jQuery.

Removing the node_modules folder in this project allowed me to add Atlas assets to any Asset Packs again. Keeping the folder and trying to add a Atlas asset to any Asset Pack causes the error logged earlier.

This Error is reproducible by creating a fresh Game Project with Typescript and add @types for Jquery to the WebContent folder through: "npm install --save "@"types/jquery".

After this, creating an Asset Pack and trying to add Atlas assets to any section causes an "Unhandled event loop exception".

PhaserEditor2D commented 6 years ago

Thanks @oskfan I will test. I have to improve the inclusion/exclusion rules on the assets discovery.

PhaserEditor2D commented 6 years ago

Hi @oskfan this is a workaround to this issue:

You can do the same procedure for all the folders you want to exclude, like the .svn one. The drawback of this method is that you are not going to see these folders anymore in the project, you have to access them in the OS explorer.

Please tell me if it works for you.

PhaserEditor2D commented 6 years ago

Done. Now when you add a new asset, it looks for those in the folder and subfolders where the "pack file" is.

For example, if the pack file is in the assets directory, it will look recursively for files inside that directory.