Jump to content

Loader not working on android with Intel XDK


skeddles
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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);

}());

 

Link to comment
Share on other sites

  • 3 weeks later...

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/

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...