Jump to content

Search the Community

Showing results for tags 'preserving objects'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hello, in my game I will be very often switching states - for example Intro and Office. In each state user can kill some objects, which were created in init function when the state was started for the first time. Lets assume that in the Office state user killed two objects, then he goes to Intro state and then back to Office - is there some way to preserve that state as it was before the state change? Without holding some global array with informations about all objects if they were killed or not? My sample code: intro.js MyGame.intro = function (game) { this.background; this.character;};MyGame.intro.prototype = { create: function () { this.background = this.add.sprite(0, 0, 'loadingBackground'); this.character = game.add.sprite(game.world.centerX, game.world.centerY, 'aml_1', 'aml_avatar_hindus.jpg'); var left = game.add.sprite(game.world.centerX-232, game.world.centerY - 200, 'aml_1', 'strzalka_lewo.png'); var right = game.add.sprite(game.world.centerX+200, game.world.centerY - 200, 'aml_1', 'strzalka_prawo.png'); this.character.anchor.setTo(0.5,0.5); var startBtn = game.add.sprite(game.world.centerX, game.world.centerY+300, 'aml_1', 'letsstart.png'); startBtn.anchor.set(0.5); startBtn.inputEnabled = true; startBtn.events.onInputDown.add(this.startClicked, this); game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; // using RESIZE scale mode game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setScreenSize(true); }, startClicked: function () { this.state.start('Office', false, false); } };office.js MyGame.office = function (game) { this.background; this.character; this.sheet; this.btn; this.zszywacz;};MyGame.office.prototype = { init: function () { this.background = this.add.sprite(0, 0, 'officeBackground'); this.sheet = this.add.sprite(game.world.centerX, game.world.centerY, 'aml_1', 'pole.png'); this.sheet.anchor.set(0.5); this.btn = this.add.sprite(game.world.centerX, game.world.centerY + 300, 'aml_1', 'play.png'); this.btn.anchor.set(0.5); this.btn.inputEnabled = true; this.btn.events.onInputDown.add(this.btnClicked, this); this.spawnHiddenObjects(); }, create: function() { }, btnClicked: function() { this.sheet.kill(); this.btn.kill(); console.log(this.sheet); }, spawnHiddenObjects: function() { this.zszywacz = this.add.sprite(1302, 587, 'aml_1', 'zszywacz.png'); this.zszywacz.inputEnabled = true; this.zszywacz.events.onInputDown.add(this.zszywaczClicked, this); }, zszywaczClicked: function() { this.state.start('Intro', false, false); } };Any help would be appreciated, thanks.
×
×
  • Create New...