shohan4556

Members
  • Content Count

    118
  • Joined

  • Last visited

Posts posted by shohan4556


  1. That should work. Try adding game.camera.unfollow() at the end of your create function. If that works then you've set the camera to follow some sprite earlier in your code(it may happen if you're using some example/template as a starting point.

    It works only when I move my hero up otherwise not. I have an idea that is create an hidden sprite give it velocity.y -=value and make camera to follow it .but its not working. actually I follow this way http://codepen.io/shohan4556/pen/KdPVNd?editors=001 but the camera follow should going up forever automatically without respect the hero. 


  2. I actually have implemented localStorage based highscore into my game here is how I did it:

    //Globals HEREvar score = 0;var highscore = 0;//Update Function HERE//Psuedo code / Real codeif(player got hit by something (in other terms, he lost the game)){  //We know before this point of losing the player actually got 'some' points   if (score > localStorage.getItem("highscore")) {                localStorage.setItem("highscore", score);            }//If the score is greater than what was stored, then I tell localStorage, "Hey set 'score' as your new stored score as the highscore now//After that I display it in the update function when the player clicks "try again" or something of the sort to reset the gamehighScoreText.content = 'HIGHSCORE: ' + localStorage.getItem("highscore");

    As you play my game you notice that if you get some amount of points and then close the game and come back, your highscore will still stay the same. 

     

     

    Hope this gave you some insight on how to approach the problem. 

     

    Do I need to set highscore before this line score>localStorage.getItem("highscore");


  3.  

    Note that you have to do something like:

    var highScore = localStorage.getItem('highscore');if(highScore  === null) { // If there is no highScore (game is started for the first time on this device)    localStorage.setItem('highscore', 0);    highScore = 0;}

    So that when the game loads you also load the high score. If you do exactly how shonan exemplified, then each time you launch the game the high score will reset to 0, which then makes the use of localStorage useless.

     

    Also, instead of declaring them globally I recommend adding them either to your game object or to a custom namespace so you don't pollute the global namespace.

     

    Something like:

    // On game load or initgame.score = 0;game.highScore = localStorage.getItem('highscore');if(game.highScore  === null) {    localStorage.setItem('highscore', 0);    game.highScore = 0;}

    if I follow your way is the score will be preserved if I reload my game ? 


  4. I was curious if there is a way to increase the rigidity of arcade sprite bodies. At the moment, they seem to overlap quite a bit, and even fall through each other at times. You can see in the gif below (and demo) that a whole row gets lost.

     

    Is there any way to completely get rid of this overlapping/fallingissue? If yes, can it be done with arcade physics, or do I need to switch to ninja or p2?

     

    Demo of issue here: http://codepen.io/jackrugile/pen/0309643b449e772eba93fc9be3c8e7be/

     

    aaXhGry.gif

    this link is dead will you please fix it . 


  5. var poly = [];// note : parsing json$.getJSON('my_assets/addPhysics/testPhysics.json', function(data) {$.each(data.rigidBodies, function(i, body) {$.each(body.polygons, function(j, polygon) {$.each(polygon, function(k, coords) {poly.push([coords.x, coords.y]);});});});});ball1.body.clearShapes(); ball1.body.addPolygon({},poly);

    I have tried this but its not working.


  6.  

    Hi,

     

    Can you upgrade Phaser to the latest version 2.4.2. You're Phaser v2.0.6. I got this error:  :(

    TypeError: this.scale.setScreenSize is not a function 

     

    But when updated the version its showing the error, 

    TypeError: this.scale.setScreenSize is not a function 

     previous version is ok. I cant understand what going on there can you please help to figure out the problem.