• Content Count

  • Joined

  • Last visited

About super_frog

  • Rank

Recent Profile Visitors

1265 profile views
  1. If you go here and search for if (clone), you will see there's no change being made and it should be like drhayes edited: var base = Array.isArray(data) ? [] : {}; return Phaser.Utils.extend(true, base, data); Me and my getJSON function.
  2. game.debug should be used for debugging only, as the name states. You're better off using and you don't need another method just to color it. When changing the graphics color, you should destroy the old one and draw a new one at the same location, with different color and add it to the same group.
  3. You can add two groups. One for sprite, other for graphic. And then bringToTop the sprite group. Something like var gs =; var gg =; var s = game.add.sprite(10, 10, 'sprite'); var g =, 0); g.beginFill(0xFFFFFF, 1); g.drawRect(10, 10, 20, 20); g.endFill(); gg.add(g); gs.add(s);;
  4. No problem. I should've explained it better with this length property like you did. I wanted to explained it better and all that text made it hard to understand. Thanks.
  5. There's no problem when using getJSON(key) function. Problem is when the second argument of the getJSON function is set to true (this.cache.getJSON('thing', true)). You can reproduce this with jsbin you've created. Set the second argument to true and run the code. You will notice that thing.length is undefined.
  6. This is the format of my JSON: [ {"i": 0, "c": 0, "end": false}, {"i": 0, "c": 0, "end": true} ]
  7. I am iterating through JSON from i = 0 to JSON.length. This length property is available when using getJSON(key), but it is not available with getJSON(key, true) and because of that, JSON.length is undefined, code did not enter the loop and nothing is displayed. I've mentioned those __proto__ functions because they are different between getJSON(key) and getJSON(key, true). It that's how it supposed to be, than it's ok. Here's screenshoot.
  8. Sorry for delayed answer. I've downloaded the dev branch, replaced phaser.js with the new one and it is not working. Length property of the JSON object is missing and __proto__ of the JSON object has different functions than the JSON object returned with getJSON(key). Here's the screenshoot
  9. Here's the fiddle - And from the Phaser documentation about getJSON getJSON function have second argument for cloning the object, but it also return some other functions, not just JSON object. I hope it's much clearer now.
  10. getJSON(key) and getJSON(key, true) doesn't return the same object. First one returns JSON object which I expect, but because getJSON(key) returns a reference to that object and if I change it, next time when I call getJSON(key) I get that changed JSON and I want initial JSON so that I can clear the awards that user has won. The second one returns an object by a value and if I modify it, it doesn't change the one in the cache (which I also want), but when I output getJSON(key, true) to the console, I get my JSON object along with some functions I don't need which breaks my function for displaying the awards. My question was how to clone/copy JSON without those extra function, just with JSON object like with the first function? I can create a fiddle to showcase the difference between getJSON(key) and getJSON(key, true) if I didn't explained it well.
  11. * If you don't want to read this background, jump to the question below. I have awards in a game and when you win each award, I mark that award in JSON object and saved it in localStorage. Those awards are loaded from JSON file on a server using game.cache.getJSON function. I also give the player option to clear the awards and start all over again. I have a global gameJSON variable where the initial JSON is loaded, where I change which award is won and gameJSON is saved to localStorage. At first, I had a problem when I was clearing the localStorage and then reloading JSON from the server for a fresh start and by visiting awards list, found out like they are never deleted, unless I refresh. I've searched and found in documentation that getJSON returns a reference and not a copy of a JSON object and if you changed it, you change it in the cache too, but there's a second argument to clone it which solved that problem. QUESTION So I've set getJSON second argument to true (to clone it) instead of passing it as a reference and when I was inspecting gameJSON object to verify it works, it did work, but I've noticed some other functions and JSON object is not like when I was loading it without cloning and awards display wasn't working. (no errors though) My question is how to clone/copy it without those extra function? I just need my JSON string. Thanks!
  12. Tweening never came up to me to use it for counting. Elegant with minimal code. But I would have to adjust both of the examples and synchronize sound with counting. For big scores is not a problem, but for small ones it is. They would slowly count up and sound needs to follow that. Thanks Zeterain and Tom for your examples.
  13. On game over I want to count score from 0 to any score user has won with the sound while counting, and it should finish fairly quickly, about few seconds no matter how big the score is. I've seen some games built in phaser that have this counting, but with minified source to be able to see how they did it. Here's jsfiddle of what I am able to come up with (it needs more adjustments to what I need), but I don't know if this is the way how they did it or is there a better way? Oh, and it should be reusable to change to another Phaser text object (game.add.text) for counting. Any information would be appreciated. Thanks!