espace

Members
  • Content count

    339
  • Joined

  • Last visited

  1. hi, how to have an object create with phaser accessible trough the different states ? Normally we have something like that : var boot = { preload: function() { this.game.load.image("loading","assets/loading.png"); }, create: function() { this.game.add.sprite(100,100;'loading'); this.game.state.start('preloader'); }, }; var preloader = { preload: function() { }, create: function() { this.game.state.start('preloader'); }, }; and what i want to do is this : var sprite=game.add.sprite(assets/loading.png) sprite.name="robert" var boot = { preload: function() { console.log(sprite.name) //robert }, create: function() { }, }; var preloader = { preload: function() { }, create: function() { console.log(sprite.name) // robert }, }; in fact i want to use the audio function from phaser outside my state and play or pause trough the different states .... is there a way to accomplish that ?
  2. hi, I have this piece of code to play my ambiance music. these function is on the top of my state to be accessible trough all the different states. Everything works fine expect when i leave the game on my phone. The music is still playing. What's the syntax for the event : to say "we leave the game" then stop the music with music_ambiance.pause(); ? var music_ambiance=new Audio('sounds/music_ambiance/mus.ogg'); music_ambiance.loop=true; music_ambiance.volume=0.20; music_ambiance.play(); //for pause //music_ambiance.pause(); music_ambiance_mute=function(){ music_ambiance.volume=0; }; music_ambiance_activate=function(){ music_ambiance.volume=0.20; };
  3. format json problem

    ok i understand what you mean => as we say the coin is fall => problem solved thanks
  4. format json problem

    Because I have developed an editor to configure my levels. I use dat.gui and I could publish the parameters of my enemies to my email. What I doesn't understand is why I have this syntax : \"parameter"\
  5. hi, I use this function to to set the storage : var logic_position=function(sprite){ if (debug_position){ hero.grid.visible=false ; var _table; var _name_json; switch(sprite.name){ case 'canon': _table=c; _name_json='canon'; _table[sprite.number] = { number:sprite.number, delay:Math.round(sprite.delay), x:Math.round(sprite.x), y:Math.round(sprite.y), speed:Math.round(sprite.speed), frequency:Math.round(sprite.frequency), variance:Math.round(sprite.variance), angular:Math.round(sprite.angular), _flag:sprite._flag, kill_with_world:sprite.kill_with_world, special_color:sprite.special_color, _rotate:sprite._rotate, _value_rotate:sprite._value_rotate, }; break; } this.level=level_number; this.name_level='lev'; this.combined_level=this.name_level+this.level; localStorage.setItem(_name_json+sprite.number+this.combined_level, JSON.stringify(_table[sprite.number]),null,"\t"); } }; console.log(localStorage) The result of the localStorage is this : { "canon0lev0": "{\"number\":0,\"delay\":0,\"x\":200,\"y\":840,\"speed\":2000,\"frequency\":60,\"variance\":20,\"angular\":180,\"_flag\":false,\"kill_with_world\":true,\"special_color\":false,\"_rotate\":false,\"_value_rotate\":10}" } And what i want is this : { canon0lev0:{ number:0, delay:0, x:200, y:840, speed:2000, frequency:60, variance:20, angular:180, _flag:false, kill_with_world:true, special_color:false, _rotate:false, _value_rotate:10} } } However i follow this link to format my json but it's not the result expected https://stackoverflow.com/questions/2614862/how-can-i-beautify-json-programmatically What i must do to have the result expected...
  6. hi, I don't really understand...who choose the bundle id ? Me or it' trough the playstore or trough iTunes when i publish my game ? Sorry but on the net i have the 2 solutions so i ask to experts ...
  7. [Construct 2] Basket Slam Dunk

    same comment
  8. weapon send a signal each time the weapon fire ?

    exactly what i needed. Thanks and a love for you because you don't have a lot
  9. hi mattstyles, when canvasplus read the index.html if in the src tag there is a file with syntax problem (eg: let value="hi") cocoon crash. So i imagine a thing like this, but unfortunately that don't work <script window.isCanvasPlus = true></script> <script !window.isCanvasPlus && src="src/webview_main.js"></script> <script window.isCanvasPlus && src="src/canvas_main.js"></script> have you a better idea ?
  10. hi, i have made a weapon based on this example : https://phaser.io/examples/v2/weapon/asteroids by reading the doc i don't find exactly how to send a signal each time the weapon fire . In fact i would play an animation each time the weapon fire. actually i use the same frequency of my weapon to play this animation but it's not a good solution in long-term.
  11. hey guys, finally i have discover what don't work in my game this snippet is unsupported by canvas+, it's on the doc => webworker. guit.parameter.onChange(function(value){ args[0].fire(); logic_position(args[0]); }); thanks also to icp for your plugin it works. A simple question is there a way to maintain this code on my main.js and by a way when on canvas+ disable this snippet to avoid black screen ?
  12. Canvas size did not change after setUserScale

    On my template check the code in index.html and in main.js => boot
  13. Newbie to phaser ( I need someone to help me plss)

    follow my template it"s a good begin especially the article : learn javascript in 5 minutes
  14. update : correcting style syntax with http://jshint.com/ add some advices to canvas+ and usefull tools for chartboost i put it later.
  15. Hi, I don't find the information on the net so : wich version of javascript(ES5, ES6 ???) is supported trough canvasplus on cocoon.io ? by test i know that these snippets are not supported when i launch my game on canvas+ : var myFunc=()=>{}; let variable; const anothervariable; Could you tell me more about that...