-
Notifications
You must be signed in to change notification settings - Fork 241
Issue loading XNA game data #734
Comments
Check the developer console for the page and you will probably see some messages about unimplemented externals. Most likely you are hitting an unimplemented constructor, unimplemented op_Multiply, or both. (If the method is unimplemented it'll return undefined, so MemberwiseClone won't work.) |
Upon checking the dev console it seems there is a bigger issue, before it aborts as shown in my first post, it fails to load my content manifest (xx.contentproj.manifest.js) because one doesn't exist! I'll have to check later why my XNA content didn't get compiled by JSIL, almost certainly my fault. I JSIL complied from a pre-built folder containing an .exe (with a folder called 'Content' full of stuff) rather than using the .sln method. |
So after some troubleshooting I managed to get my XNA content project to compile with JSIL (yay!), and now I notice some errors regarding unimplemented externals, followed by an app crash afterwards, any advice on how to combat this? The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.GameComponentCollection' has not been implemented; calling inherited method. The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.BlendState' has not been implemented; calling inherited method. The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.GraphicsResource' has not been implemented; calling inherited method. The external method 'void .ctor()' of type 'System.IO.Stream' has not been implemented; calling inherited method. The external method 'void .ctor()' of type 'System.MarshalByRefObject' has not been implemented; calling inherited method. The external method 'System.Int32 ReadByte()' of type 'System.IO.MemoryStream' has not been implemented; calling inherited method. The external method 'System.Single ReadSingle()' of type 'Microsoft.Xna.Framework.Content.ContentReader' has not been implemented; calling inherited method. The external method 'HackAttack.Base_Classes.Wave Peek()' of type 'System.Collections.Generic.Queue`1' has not been implemented. Uncaught TypeError: Cannot read property 'Start' of undefined HackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1542 WaveManager_StartNextWaveHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1437 WaveManager__ctorHackAttack.Base_Classes.WaveManager:39 HackAttack_Base_Classes_WaveManagerHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3044 Game1_LoadContentXNA4.js:1284 Game_InitializeHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3002 Game1_InitializeXNA4.js:1370 Game_Run(index):57 runMainJSIL.Browser.js:1138 browserFinishedLoadingCallback |
Queue.Peek looks like the problem here. It's returning undefined instead of On 29 April 2015 at 13:35, hevans90 notifications@github.com wrote:
|
Interesting. Am I right in thinking that 'undefined' in JavaScript relates to a variable has been declared but has not yet been assigned a value? Because if so this has me puzzled... I just checked the C# code of the class that is playing up, and I define a Queue as a field at the top of my class which then gets passed in to the constructor and gets enqueued with objects (Waves in this case) BEFORE any Peeks are invoked. Hence in my C# class the Queue always has values to be Peeked at, so I'm not sure how the JavaScript is managing to find an empty queue :( Looking at the equivalent JavaScript class the logic seems identical, there is a Queue declared here: var $T07 = function () { Below which the class constructor enqueues objects in to the queue: $T07().prototype.Enqueue.call(this.waves, wave); And at the very end of the constructor a method is called that Peeks the Queue: function WaveManager_StartNextWave () { Can you see anything I'm missing? |
It doesn't mean the queue is empty, it means the Peek method is 'undefined' is a value type in JS, like null or false or true. On 29 April 2015 at 14:11, hevans90 notifications@github.com wrote:
|
Well I guess that serves me right for trusting the first explanation Google gave me, thank you for explaining what is going on here. I am still confused as to why Peek isn't being implemented though, and am unsure how to go about ensuring it is implemented. |
It's probably missing from the bootstrap libraries. I'll do some looking On 29 April 2015 at 14:36, hevans90 notifications@github.com wrote:
|
Sorry, didn't get to this until now - it appears to be as simple as that Stack.Peek is implemented and Queue.Peek is not. This is pretty trivial to fix and I might be able to check in a fix this week if I find some time. If you'd like to fix it yourself, I'd be happy to guide you through the process and then I can merge your changes in. You'd be essentially adding a method to JSIL.Bootstrap.js's Queue implementation similar to Stack.Peek (above it in the file). |
Oh awesome! Sure, I'd love to give it a try. Would it just involve opening the solution in visual studio, editing a .js file and then rebuilding it before running it on my app again? If the Stack.Peek method is already there in the JavaScript somewhere I can probably just copy the syntax for Queue.Peek right? |
Apologies for taking so long to get back to you on this, but life as a developer can get stupidly busy sometimes as you probably know... So I tried to add a new method to the JSIL.bootstrap, mimicking the Stack.Peek() one: $.Method({ Static: false, Public: true }, "Peek", I compiled it, re-applied JSIL to my game, and dumped the new output files in to my mockup local website. It worked without any game breaking JS errors this time! However there is something wrong with the method I added, because the Queues are not acting as they should, and my game sprites simply progress from the first entry in the queue to the last entry, without checking the intermediary ones. The way I coded it in C# was as such: Sprite has a Queue of integer values representing waypoints on a map. Every game update (some thousands of a second) each sprite checks if it has reached the next value in the queue by Peek()ing the queue, and if it has it will progress on to the next waypoint, repeating such logic until the end of the queue. I can't see why this would occur, can you? |
You mirrored Stack.Peek, what you want is this._items[0]. |
Excellent, I'll make that change and check it in for you tonight. I found another issue while we are at it, the C# code I wrote to make the missiles 'homing' is broken when compiled to JScript.
I don't have the JSIL generated JS on me right now at work but it seemed a little strange. There were no 'unimplemented externals' errors though, instead the directional part of the velocity vector is always unchanged, i.e. the bullets shoot straight up and don't chase the targets. I can obviously manually recode a new method to replace Vector2.Transform, but just thought I should let you know. |
JSIL's matrix implementation is a busted hack atm, so that might be why. If |
Hi there, I have only just discovered JSIL and am already a huge fan!
I recently tried to compile my C# XNA 4.0 game using the latest version of JSIL, and it seemed to work fine. I then hosted it locally (using your example web.config and index.html) and the canvas loads fine in Chrome, but when I try to click 'Load Game' inside the canvas the data loads until a certain point in my newly-compiled javascript code and then fails with this error:
Loading data ... failed.
Unhandled exception at http://localhost/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js line 496:
Unable to get property 'MemberwiseClone' of undefined or null reference
So I had a look at the javascript and it stops loading here:
I am no JavaScript developer but from the looks of it, there seems to be an issue with the MemberwiseClone() JavaScript method as noted here: LINK
Just looking at the syntax of the method in the above link suggests that the JavaScript version of MemberwiseClone() needs a colon after it followed by the desired object to clone, and the above auto-generated code doesn't seem to have this colon or object reference.
I'm sure I'm wrong but that's all I could come up with!
Any help would be more than appreciated! Thanks.
The text was updated successfully, but these errors were encountered: