• Content Count

  • Joined

  • Last visited

  1. Thank you so much! It worked perfectly
  2. In my game I have the camera following the main player. But im trying to display the health in the top left corner of the screen with images. The problem is when my player moves so that the camera has to follow, the hearts gets left behind. How can i fix that? Any help would be amazing thank you!
  3. I have to store a list of items in in localStorage. The problem is when i try to store the whole list because there are multiple item in the list, it just says Nan Potato.upgradeButtonsData = [ {icon: '1stUpgrade', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: "Buy some mighty hands... and increase your\nPAS.", name: 'Click Power ', level: 1, cost: 100, pas: 0.2, purchaseHandler: function(button, player){ Potato.player.clickDmg += 0.2; }}, {icon: '2ndUpgrade', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: "Tatoes are small helpers which increase\nyour PAS.", name: 'Tatoes ', level: 1, cost: 500, pas: 0.5, purchaseHandler: function(button, player){ Potato.player.pas += 0.5; }}, {icon: 'chipFactory', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: "Chip Factory generates alot of chips,\nwhich will increase your PAS.", name: 'Chip Factory ', level: 1, cost: 1000, pas: 0.7, purchaseHandler: function(button, player){ Potato.player.pas += 0.7 }}, {icon: 'potatoFarm', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: 'The Potato Farmers has been farming potatoes\nfor decades, they will increase your PAS', name: 'Potato Farm', level: 1, cost: 5000, pas: 1, purchaseHandler: function(button, player){ Potato.player.pas += 1; }}, {icon: 'fingerChips', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: 'Delicous Potato Fingers made with secret\ningredients, increases your PAS', name: 'Finger Chips', level: 1, cost: 10000, pas: 3, purchaseHandler: function(button, player){ Potato.player.pas += 3; }} ]; I am trying to store the level, cost and pas values in localStorage for each item. So if we say the last 'fingerChips' is level 1, and the '1stUpgrade' is level 3, then it would store that the '1stUpgrade' is level 3, and the 'fingerChips' is level 1, but i dont have to store the text because that will always be the same. When i then load the page again it would remember that the '1stUpgrade' is level 3, and the 'fingerChips' is level 1
  4. I am trying to store from this code: Potato.upgradeButtonsData = [ {icon: '1stUpgrade', PIcon: 'potato4Upgrade', background: 'upgradeBg', themeText: "", name: '', level: 1, cost: 100, pas: 100, purchaseHandler: function(button, player){ Potato.player.clickDmg += 0.2; }}, But the problem is that when I try it either says "Nan" or will just do nothing. I am using localStorage because i could not get the store.js thing to work. And if you have to store all the items(by all the items i just mean (level, cost and pas)) like an Array then I dont know how to. I am pretty new to Phaser This is the code I am using to store the items in the list: if(localStorage.getItem('numL') === null){ console.log("Creating localStorage 'numL"); localStorage.setItem('numL', Potato.upgradeButtonsData.level); } if(Potato.upgradeButtonsData.level >= 1){ Potato.upgradeButtonsData.level = localStorage.getItem('numL'); } Potato.upgradeButtonsData.level = parseInt(localStorage.getItem('numL')); And in the update method: localStorage.setItem('numL', Potato.upgradeButtonsData.level); Any help would be awesome! EDIT: I have more than 1 item in the lists in my actual code, this is just an example
  5. No. Because i found out What the problem Was. I just had to add a group i had made AS a child instead of the one item
  6. I cant figure out how i would be able to add a function as a child, the function spawns items at the top of the screen and then they fall to the bottom where they will be killed. But if i add a background the items spawn behind that background. i cant figure out how they will be able to spawn infront of the background any help would be greate! Here im trying to add the items as a child Potato.SpawnPotato = this.mainBackground.addChild(game.potato); And this is the code which holds game.potato Potato.item = { spawnPotato: function(game){ game.world.enableBody = false; game.physics.startSystem(Phaser.Physics.ARCADE) game.physics.arcade.gravity.y = 200; var dropPos = Math.floor(Math.random()*650); var dropOffSet = [-27, -36, -36, -38, -48]; var potatoType = Math.floor(Math.random()*5); var potato = game.add.sprite(dropPos, dropOffSet[potatoType], 'FallingPotato'); potato.animations.add('anim', [potatoType], 10, true); potato.animations.play('amim'); game.physics.enable(potato, Phaser.Physics.ARCADE); potato.inputEnabled = false; potato.anchor.setTo(0.5, 0.5); potato.rotateMe = (Math.random()*4)-2; game._potatoGroup.add(potato); potato.checkWorldBounds = true; potato.events.onOutOfBounds.add(this.removePotato, this) }, removePotato: function(potato){ potato.kill(); } }