skeddles Posted March 31, 2016 Share Posted March 31, 2016 So I have an app in progress which 100% works on desktop and in XDK's emulate tab. When I play the app on my phone, it does not work. I discovered it's crashing when it's trying to load a bitmap font with the loader function. Here is my code: PIXI.loader.add('thintel', 'thintel.fnt'); PIXI.loader.once('complete',initRooms); PIXI.loader.load(); The initRooms() function never gets triggered. Any ideas? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 31, 2016 Share Posted March 31, 2016 Something-something XML parser? Quote Link to comment Share on other sites More sharing options...
skeddles Posted April 1, 2016 Author Share Posted April 1, 2016 21 hours ago, ivan.popelyshev said: Something-something XML parser? Do you mean desktop browsers have an xml parser and mobile do not? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 1, 2016 Share Posted April 1, 2016 Yeah, its possible. Im working on parser for https://github.com/libgdx/libgdx/wiki/Hiero format, it wont require xml Quote Link to comment Share on other sites More sharing options...
skeddles Posted April 2, 2016 Author Share Posted April 2, 2016 6 hours ago, ivan.popelyshev said: Yeah, its possible. Im working on parser for https://github.com/libgdx/libgdx/wiki/Hiero format, it wont require xml Is there any other options? Can I somehow tack on an xml parser? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 2, 2016 Share Posted April 2, 2016 You can make your own loader for .fnt file that is not dependent on xml. Look at that thing: https://github.com/pixijs/pixi.js/blob/master/src/loaders/bitmapFontParser.js . MAy be use some popular xml parsing lib? Quote Link to comment Share on other sites More sharing options...
xerver Posted April 4, 2016 Share Posted April 4, 2016 The XML parser is the built-int browser one that comes with XHR2. Most modern browsers (including mobile) should have it. What is the error you get? http://caniuse.com/#feat=xhr2 Quote Link to comment Share on other sites More sharing options...
skeddles Posted April 6, 2016 Author Share Posted April 6, 2016 On 4/4/2016 at 10:58 AM, xerver said: The XML parser is the built-int browser one that comes with XHR2. Most modern browsers (including mobile) should have it. What is the error you get? http://caniuse.com/#feat=xhr2 I can't seem to get any errors out of it. I tried using the remote debug script and overwriting the console functions with alert functions, but don't see anything. I tried starting from scratch and this time it doesn't crash, but instead just doesn't draw the text. Still works fine on desktop and the emulate tab. Here is my code, very similar to the default pixi template: /* jshint browser:true */ /* globals PIXI, requestAnimationFrame */ (function() { document.addEventListener('DOMContentLoaded', function() { /* window.console = { log: function(input){ alert(input); }, warn: function(input){ alert(input); }, error: function(input){ alert(input); }, } */ // create an new instance of a pixi stage var stage = new PIXI.Container(); // create a renderer instance var width = screen.availWidth; var height = screen.availHeight; var renderer = new PIXI.autoDetectRenderer(width, height, {backgroundColor : 0x444444}); // add the renderer view element to the DOM document.body.appendChild(renderer.view); requestAnimationFrame(animate); // create a texture from an image path var texture = PIXI.Texture.fromImage("asset/bunny.png"); // create a new Sprite using the texture var bunny = new PIXI.Sprite(texture); // move the sprite to the center of the screen bunny.position.x = 20; bunny.position.y = 20; stage.addChild(bunny); var text; PIXI.loader.add('thintel', 'thintel.fnt'); PIXI.loader.once('complete',function () { text = new PIXI.extras.BitmapText('lol', {font: "10px Thintel"}); //text.scale.set(zoom, zoom); text.position.x = 10; text.position.y = 10; stage.addChild(text); }); PIXI.loader.load(); function animate() { requestAnimationFrame(animate); // just for fun, let's rotate mr rabbit a little //bunny.rotation += 0.1; // render the stage renderer.render(stage); } }, false); }()); Quote Link to comment Share on other sites More sharing options...
skeddles Posted April 24, 2016 Author Share Posted April 24, 2016 Still having issues with this. I tried it in a regular web browser, chrome for android, and it works. Shouldn't anything that works in the browser work in XDK? Is this possibly an xdk problem and not Pixi.js? I also tried renaming the file from .fnt to .xml, but it didn't change anything. You can see my live demo here: http://wearpixels.com/adventure16/fontest/ Quote Link to comment Share on other sites More sharing options...
skeddles Posted April 30, 2016 Author Share Posted April 30, 2016 Oh holy crap guys I think I fixed it. So I finally figured out how to debug XDK, and found I was getting this error overrideXMLHttpRequest.js:16 Uncaught TypeError: Cannot call method 'startsWith' of undefined (anonymous function) Resource._xhrOnLoad Still no idea what that means, but looking at that file I found that it said: //this is a workaround for HTML-7506 //file://android_asset requests get status 200 OK upon success //regular file requests that succeed get status 0 "" //this difference breaks frameworks like cocos2d that use XHR but treat non-200 status as an error //the workaround is to return 200 OK when readyState is 4, status is 0 and responseURL is not "" // //to disable, add "data-noxhrfix" to head (e.g., <head data-noxhrfix>) // So I disabled it like it said, and it solved the issue. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.