Search the Community

Showing results for tags 'switching'.



More search options

  • 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 Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

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 2 results

  1. Hi guys, I was trying to find an answer to this but had some problems (maybe my Google-fu is just a little off today). Thankfully, I figured out the answer myself. Assuming you have a character walking around in a world of containers (for example, walking from one zone to the other where each zone is a container that is next to the other) the calculation is: newX = oldX + (oldContainerX - newContainerX); newY = oldY + (oldContainerY - newContainerY); and a real code example: if(buckets['walking'].parent){ var newX = buckets['walking'].position.x + (buckets['walking'].parent.position.x - buckets.biomes[overlappingBiomes[0]].scen.position.x); var newY = buckets['walking'].position.y + (buckets['walking'].parent.position.y - buckets.biomes[overlappingBiomes[0]].scen.position.y); // buckets['walking'].parent.removeChild(buckets['walking']); buckets.biomes[overlappingBiomes[0]].scen.addChild(buckets['walking']); buckets['walking'].position.x = newX; buckets['walking'].position.y = newY; } Hopefully this helps someone! Cheers
  2. 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.