Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by SteveB

  1. Has anyone had any success using Phaser offline using a manifest file.


    I've set up a manifest file to allow offline use. Works fine everywhere I've tested except on my iPad. The first time, when it downloads the files, it works fine. The second time it just stops.


    I traced it down to the audio.

    /**    * Called when a file is successfully loaded.    *    * @method Phaser.Loader#fileComplete    * @param {number} index - The index of the file in the file queue that loaded.    */    fileComplete: function (index) {...  case 'audio':                if (this.game.sound.usingWebAudio)                {                    file.data = this._xhr.response;                    this.game.cache.addSound(file.key, file.url, file.data, true, false);                    if (file.autoDecode)                    {                        var that = this;                        var key = file.key;                        this.game.cache.updateSound(key, 'isDecoding', true);                        this.game.sound.context.decodeAudioData(file.data, function (buffer) {                            if (buffer)                            {                                that.game.cache.decodedSound(key, buffer);                                that.game.sound.onSoundDecode.dispatch(key, that.game.cache.getSound(key));                            }                        });                    }

    The problem is that once the files have been cached, the file.data = this._xhr.response is null and that causes a DOM exception 12 error when the sound is added.



  2. Any idea why I can't get the game onBlur to fire. I intended to use it to stop background music playing when the game loses focus. I've cut everything down to this:

    game.onBlur.add(function() {    console.log("BLURRED");}, this);

    I can see that the game object has the signals added but the function never gets called. Have I missed something?


  3. Thanks for the feedback turnA. I hadn't thought of M? meaning I was asking for the M symbol. I'll change the ? into something more intuitive. The _ is a bit close to some of the symbols but I'll think of something.

  4. I've got a problem with bitmap fonts in IE11. The game I've put together works fine in Chrome, Firefox, Opera, and Safari but falls over in IE11. Any ideas? Using Phaser 2.0.1



    SCRIPT5009: 'Float32Array' is undefined

    File: phaser.js, Line: 57295, Column: 5

    vec2.forEach = (function() {    var vec = new Float32Array(2);

    SCRIPT5007: Unable to get property 'responseText' of undefined or null reference

    File: phaser.js, Line: 41759, Column: 17

    bitmapFont: function (game, xml, cacheKey, xSpacing, ySpacing) {        if (!xml || /MSIE 9/i.test(navigator.userAgent))        {            if (typeof(window.DOMParser) === 'function')            {                var domparser = new DOMParser();                xml = domparser.parseFromString(this.ajaxRequest.responseText, 'text/xml');            }

    I've extracted the key parts of the code into a test shell as shown here. 

    <html><head>	<title>Runes</title>	<meta charset="utf-8">	<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=9">	<meta name="format-detection" content="telephone=no">	<meta name="HandheldFriendly" content="true" />	<meta name="apple-mobile-web-app-capable" content="yes">	<meta name="apple-mobile-web-app-status-bar-style" content="black">	<meta name="format-detection" content="telephone=no">	<meta name="HandheldFriendly" content="true" />	<meta name="robots" content="noindex,nofollow" />	<meta name="apple-mobile-web-app-capable" content="yes" />	<meta name="apple-mobile-web-app-status-bar-style" content="black" />	<meta name="apple-mobile-web-app-title" content="Phaser App">	<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0 minimal-ui" />	<link rel="apple-touch-icon" href="/apple-touch-icon.png">	<link rel="stylesheet" href="css/stylesheet.css" type="text/css" charset="utf-8" />	<script src="phaser.js"></script></head><body>    <script type="text/javascript">        var console=console || {"log": function(){}};        var game;        var State = function (game) {            this.ready = false;        };        State.prototype = {            preload: function() {                this.load.bitmapFont('mainFont', 'architects_daughter.png', 'architects_daughter.xml');            },            create: function() {                bmpText = game.add.bitmapText(200, 100, 'mainFont','Test', 32);            }        };        window.onload = function() {            game = new Phaser.Game(600, 480, Phaser.AUTO, 'game');            game.state.add('Boot', State);            game.state.start('Boot');        };    </script></body></html>

    The files are hosted here: http://henspace.com/games/_debug/index.html



  5. Have you thought of using a Tilemap to represent the 2D array? Tilemap already has methods for swaping tiles etc. If you want to extend do something like

    var MySuperTilemap = function(game, key, tileWidth, tileHeight, width, height) {    Phaser.Tilemap.call(this, game, key, tileWidth, tileHeight, width, height);    // @todo my construction stuff};MySuperTilemap.prototype = Object.create(Phaser.Tilemap.prototype);MySuperTilemap.prototype.constructor = MySuperTilemap;MySuperTilemap.prototype.coolMethod = function(something) {    //@todo more stuff};
  6. I don't know if it helps with the image loading issues. I've been battling away to get CocoonJS working. I've came across this issue, which make no sense to me, but might help someone who know what is going on, to pinpoint the image loading issue.


    I've got three groups, DPR.background, DPR.midground, and DPR.foreground. I've also got three sprites, DPR.bot, DPR.player and DPR.carriedTile. The first two go in the midground and the last in the foreground. Then for debugging purposes I've added 5 extra sprites. In the following code they go in the foreground group.


    When I do this, only the DPR.player, DPR.bot,  and DPR.carriedTile are displayed in CocoonJS, i.e the 5 debug Sprites do not appear. However, later on in the game, when the DPR.player and DPR.bot are killed, the 5 Sprites appear. They disappear when DPR.player and DPR.bot  are revived.

    DPR.midground.add(DPR.bot);DPR.midground.add(DPR.player);        DPR.foreground.add(DPR.carriedTile);var sp;for (var n = 0; n < 5; n++) {    sp = new TrackerSprite(32 * (n + 1), 32, 'carriedTiles');    DPR.foreground.add(sp);    sp.frame = 1; }

    If I change it so that the 5 debug sprites go in the midground group like so:

    DPR.midground.add(DPR.bot); DPR.midground.add(DPR.player);         DPR.foreground.add(DPR.carriedTile); var sp; for (var n = 0; n < 5; n++) {      sp = new TrackerSprite(32 * (n + 1), 32, 'carriedTiles');      DPR.midground.add(sp);      sp.frame = 1;  }

    then the 5 Sprites appear but the DPR.carriedTile, the only one in the foreground, now vanishes. However, it appears when the first 2 Sprites, DPR.player and DPR.bot are killed; it disappears when they are revived.


    It makes no sense to me and my head is beginning to hurt.


    Forgot to say: everything works as you'd expect in the browser; the strange behaviour only occurs in CocoonJS.

  7. What's the best way to reset/reload a tilemap? I've basically loaded a tilemap from JSON and during the game, lots of tiles get shifted around. What I need to do is reset the tilemap back to its start state. At the moment I just destroy the old map and then recreate it. But that puts it above the existing sprites and I finish up destroying those and then recreating them as well; I couldn't see how to alter the z order of the tilemap.


    Although it all works, I'm obviously doing this wrong.

  8. Thanks Karma Octopus. Unfortunately, not quite. The tileStrip is a sprite using the same tileset image as the map, but the individual tiles on mouse down are created using the index into the tileStrip rather than creating new Sprites; the tileStrip is still the size of the entire tileset image. My problem would be a bit like trying to make the tileStrip the size of one tile and then able to change the tile it shows.


    Mind you the example showed me a couple of other things I didn't know.

  9. I have a tilemap that's working fine. What I want to do is to create a Sprite that can be based on the same tileset as the tilemap uses so I can create dynamic tiles.


    I've extracted some of my code from some objects below to make what I'm effectively doing at the moment a bit clearer.

    var map = game.add.tilemap(mapId);map.addTilesetImage(tilesetName, imageId);var carriedTile = new Phaser.Sprite(game, 100, 64, imageId);game.add.existing(carriedTile);

    What I get, as expected, is a Sprite that displays the entire tileset image. What I need to do is to get a Sprite that only displays one tile from the Tileset. How do I achieve that? I've tried setting the textureRegion, but that doesn't seem to do anything.



  10. I've set up a chain of tweens by chaining the 'to' method. e.g.

     this.tween.to({angle: 180}, 2000, Phaser.Easing.Linear.None).     to({x: 300}, 3000, Phaser.Easing.Linear.None);

    but I need to be able to stop the tweens. If I call stop on the parent (this.tween) that stops it in its tracks but the other one then starts. How do I stop the entire chain.


    I could write some manager to keep track of them but I'm sure that's not the way to do it. I saw the TweenManager has a removeAll but that looks like it would take out other chains as well.


  11. I should have looked at the source a bit more carefully. The old swaptiles example at http://gametest.mobi/phaser/examples/_site/view_full.html?d=tilemaps&f=swap+tiles.js&t=swap%20tiles has:

    game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON);game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1);

    the latest source at https://github.com/photonstorm/phaser/blob/master/examples/tilemaps/swap%20tiles.js has:

    game.load.tilemap('desert', 'assets/tilemaps/maps/desert.json', null, Phaser.Tilemap.TILED_JSON);game.load.image('tiles', 'assets/tilemaps/tiles/tmw_desert_spacing.png');

    So  I reckon just change to load.image. I presume that the new tilemap picks up margins from the map definition rather than what would have been the tileset. I haven't tried this yet as I not at my dev. PC.

  12. I've got the same issue although I'm creating a tilemap from JSON. My code was based on the examples that use game.load.tileset but that doesn't seem to be anywhere. Anyone know the correct way of loading the tileset? I saw in another post someone using game.load.image but that doesn't allow the margins to be set.

  • Create New...