Search the Community
Showing results for tags 'local_storage'.
-
hi, i would use the local storage to store value of my object. i set the object draggable and when the drag stop i would reveal parameter of this object. the problem is that i have this error : Uncaught TypeError: Converting circular structure to JSON i follow this part of tutorial : var car = {}; car.wheels = 4; car.doors = 2; car.sound = 'vroom'; car.name = 'Lightning McQueen'; console.log( car ); localStorage.setItem( 'car', JSON.stringify(car) ); console.log( JSON.parse( localStorage.getItem( 'car' ) ) ); But in my case that don't work. Why ? Thanks for your help. https://jsfiddle.net/espace3d/cmd0158g/ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:preload, create: create }); function preload() { game.load.image('circle', 'https://s13.postimg.org/xjhlzmiev/disc_png.png'); } function create() { this.projectile=game.add.sprite(200,200,'circle') this.projectile.number=1 this.projectile.name="weapon" this.projectile.inputEnabled=true this.projectile.input.enableDrag(true) this.projectile.events.onDragStop.add(reveal_param,this) } var reveal_param=function(sprite){ localStorage.setItem('_projectile', JSON.stringify(sprite)); var _projectile_var= JSON.parse( localStorage.getItem( '_projectile' ) ) ; alert(_projectile_var.name) }
- 8 replies
-
- json
- local_storage
-
(and 1 more)
Tagged with: