trpzn

Members
  • Content count

    9
  • Joined

  • Last visited

About trpzn

  • Rank
    Newbie

Contact Methods

  • Twitter
    trpzn
  1. thanks you very much @fitness23 it works =D! I'll push the fix to the git repo
  2. @Anderberg I think the error is still alive, could you re upload the dropbox fix?
  3. help? xD
  4. I'm currently working on a jukebox in phaser but i found a big problem, when change more than 17 song mobile devices crushes. I start looking the memory usage on chrome and see that although i use audio destroy, clear game cache, and reset references memory usage keep rise song by song loaded. I could not find a solution in phaser so do the same example with howler, and it happened the same, the use of memory kept going up. Search the forums and find this interesting solution / advice that incredibly worked Is it possible to use the html5 tag in one audio and the webaudio Api in another on phaser? or fix the high memory usage? With this solution in my example i pass from 400mb on memory to 80mb on memory. The code: phaser-howler: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create ,update: update}); function preload() { game.load.spritesheet('button', 'assets/flixel-button.png', 80, 20); game.load.bitmapFont('nokia', 'assets/nokia16black.png', 'assets/nokia16black.xml'); game.load.json('audios', 'assets/audios.json', false); } var currentSong; var songList; var prevSong; var nextSong; var currIndex = -1; var logYPosition = 0; var logYSeparation = 2; var fontSize = 16; var currentTextLog; var timer = 0; var initTimer = 0; var downloadTime = 0; var decodingTime = 0; var songLength = 0; var audioFolder = ""; var repTime = 1*1000; var volume = 0.5; var readyToplay = false; var ended = false; var tempjs = undefined; function create() { tempjs = game.cache.getJSON('audios'); game.stage.backgroundColor = "#FFFFFF"; songList = tempjs.files; audioFolder = tempjs.audiosource; startNextSong(); } function startNextSong(){ currIndex++; initTimer = 0; downloadTime = 0; decodingTime = 0; songLength = 0; if(currIndex>songList.length) { game.add.bitmapText(10, logYPosition + 7, 'nokia', "no more songs in playlist", fontSize); ended = true; return; } logYPosition += fontSize + logYSeparation; var audios = _getAudioFilesArray(audioFolder,songList[currIndex],tempjs.audiotypes); initTimer = game.time.time; currentSong = new Howl({ src: audios, html5: true }); currentSong.once('load', songLoadComplete); currentTextLog = game.add.bitmapText(10, logYPosition + 7, 'nokia', "Downloading song " + currIndex, fontSize); } function songLoadComplete(){ downloadTime = game.time.time - initTimer; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ " Decoding file..."; initTimer = game.time.time; currentSong.play(); readyToplay = true; } function _getAudioFilesArray(audioFolder,audioName,audiotypes){ var returnArray = []; for(var audiotype in audiotypes){ var audio = audiotypes[audiotype]; returnArray[audiotype] = audioFolder+audioName+audio; } return returnArray; } function update(){ if(ended){ return; } if(currentSong!= undefined && currentSong.playing() && readyToplay){ var playingTime = (repTime - currentSong.seek()*1000); currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ "ms Decoding time: " + decodingTime + "ms Playing " + playingTime; } if(currentSong!= undefined && readyToplay && currentSong.playing() && (currentSong.seek()*1000>repTime)){ currentSong.stop(); currentSong.unload(); currentSong = undefined; readyToplay = false; startNextSong(); } } phaser-only: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create ,update: update}); function preload() { game.load.spritesheet('button', 'assets/flixel-button.png', 80, 20); game.load.bitmapFont('nokia', 'assets/nokia16black.png', 'assets/nokia16black.xml'); game.load.json('audios', 'assets/audios.json', false); } var currentSong; var songList; var prevSong; var nextSong; var currIndex = -1; var logYPosition = 0; var logYSeparation = 2; var fontSize = 16; var currentTextLog; var timer = 0; var initTimer = 0; var downloadTime = 0; var decodingTime = 0; var songLength = 0; var audioFolder = ""; var repTime = 1*1000; var volume = 0.5; var readyToplay = false; var ended = false; var tempjs = undefined; function create() { tempjs = game.cache.getJSON('audios'); game.stage.backgroundColor = "#FFFFFF"; songList = tempjs.files; audioFolder = tempjs.audiosource; startNextSong(); } function startNextSong(){ currIndex++; initTimer = 0; downloadTime = 0; decodingTime = 0; songLength = 0; if(currIndex>songList.length) { game.add.bitmapText(10, logYPosition + 7, 'nokia', "no more songs in playlist", fontSize); ended = true; return; } logYPosition += fontSize + logYSeparation; game.load.onLoadComplete.removeAll(); var audios = _getAudioFilesArray(audioFolder,songList[currIndex],tempjs.audiotypes); game.load.audio(songList[currIndex],audios,false); initTimer = game.time.time; game.load.onLoadComplete.add(songLoadComplete, this); currentTextLog = game.add.bitmapText(10, logYPosition + 7, 'nokia', "Downloading song " + currIndex, fontSize); game.load.start(); } function songLoadComplete(){ downloadTime = game.time.time - initTimer; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ " Decoding file..."; initTimer = game.time.time; currentSong = game.add.audio(songList[currIndex],0); currentSong.onPlay.addOnce(songLoadDecode,this); currentSong.play(); } function _getAudioFilesArray(audioFolder,audioName,audiotypes){ var returnArray = []; for(var audiotype in audiotypes){ var audio = audiotypes[audiotype]; returnArray[audiotype] = audioFolder+audioName+audio; } console.log(returnArray); return returnArray; } function songLoadDecode(){ decodingTime = game.time.time - initTimer; console.log(currentSong.isDecoding); currentSong.volume = volume; readyToplay = true; } function update(){ if(ended){ return; } if(currentSong!= undefined && currentSong.isPlaying && readyToplay){ var playingTime = (repTime - currentSong.currentTime)/1000; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ "ms Decoding time: " + decodingTime + "ms Playing " + playingTime; } if(currentSong!= undefined && readyToplay && currentSong.isPlaying && (currentSong.currentTime>repTime)){ currentSong.stop(); currentSong.destroy(); console.log(songList[currIndex]); game.cache.removeSound(songList[currIndex]); readyToplay = false; startNextSong(); } }
  5. I'm trying to build an animation manager to pack animations and launch each one at certain time. example: animation 1 launch, animation 2 wait 300ms with game.time.events Problem: in pc the difference it's only visible in frame rate but in cellphone second animation stop first and seems very ugly. code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });function preload() { game.load.spritesheet('cthulhu', 'cthulhu.png', 700, 350); game.load.spritesheet('scroll', 'scroll.png', 700, 350); game.load.spritesheet('dead', 'dead.png', 700, 350);}function create() { game.add.text(400,100,'Click to play and recharge animation'); game.input.onDown.add(playAnimations, this); this.sprite1 = undefined; this.sprite2 = undefined; this.last = 1;}function playAnimations() { console.log(this.sprite1); console.log(this.last); if(this.sprite1 != undefined){ this.sprite1.destroy(); this.sprite2.destroy(); this.sprite1 = undefined; this.sprite2 = undefined; } this.sprite2 = game.add.sprite(0, 0, 'scroll'); this.sprite2.animations.add('walk', [0, 1, 2, 3, 4, 5]); this.sprite2.animations.play('walk', 12, false,false); if(this.last == 1){ game.time.events.add( 200, function(){ this.sprite1 = game.add.sprite(0, 0, 'cthulhu'); this.sprite1.animations.add('walk', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],12,true); this.sprite1.animations.play('walk', 12, false,false); }, this); }else{ game.time.events.add( 200, function(){ this.sprite1 = game.add.sprite(0, 0, 'dead'); this.sprite1.animations.add('walk', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],12,true); this.sprite1.animations.play('walk', 12, false,false); }, this); } if(this.last == 1){ this.last = 2; }else if(this.last == 2){ this.last = 1; }}I cant pack in atlas because i need one or more animations be playing at the same time, plus i have 20+ animations and jump between big atlas (8000*8000px) seems very laggy. demo: demolink (push to play anims)
  6. I have a grid with sea tiles that have 6 frames, in the beginning all seems be synchronized because all are created in the same time, but later when i click in one sprite, change the sprite animation to other with the same background but still 6 frames. For this reason i need to launch the new animation in the same frame. I think wait for the first frame will introduce lag in the click-change-sprite and will seems ugly.
  7. nobody knows a solution?
  8. I need to launch a copy of an animation runing in the game but in coordinate way, that means launch the new animation in the same frame of the old one. it's this possible with phaser? -reset the old animation to first frame not is a solution (ugly jump). -changing the index of new animation dont seems to work. Any possible solution?