Search the Community

Showing results for tags 'place'.



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
    • 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 1 result

  1. I'm making a vertical scrolling platform game using Phaser, but I can't figure out how to create randomly placed platforms to jump on. This is the code I have so far (removed unneccesary stuff): Platformer.Game = function (game) { this._platforms = null; this._platform = null; this._numberOfPlatforms = 15; this._x = this.x; this._y = this.y; }; Platformer.Game.prototype = { create: function (){ this.physics.startSystem(Phaser.Physics.ARCADE); this.physics.arcade.gravity.y = 200; this._platforms = this.add.group(); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(this); game.camera.follow(this._player); }, managePause: function () { this.game.paused = true; var pausedText = this.add.text(100, 250, "Game paused. Click anywhere to continue.", this._fontStyle); this.input.onDown.add(function(){ pausedText.destroy(); this.game.paused = false; }, this); }, update: function () { } }; Platformer.platform = { createPlatform: function (game) { var posX = Math.floor(Math.random() * Platformer.GAME_WIDTH * this._numberOfPlatforms * 70); var posY = Math.floor(Math.random() * Platformer.GAME_HEIGHT * this._numberOfPlatforms * 50); var platform = game.add.sprite(posX, posY, 'platform'); game._platforms.add(platform); platform.events.onOutOfBounds.add(this.removePlatform, this); }, removePlatform: function (game) { this._platform.kill(); } } I can get it to work to place them randomly, but the idea of a platformer should be you could actually jump on it... With enough distance but not too much, so I guess not entirely random. Hope you have some ideas! Thanks in advance.