Jump to content

Search the Community

Showing results for tags 'phasercollision'.

  • 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. I am making a flappy bird game using phaser.js. My problem is that it doesn't collide with the ledges. And how do you change the camera (you know in flappy bird they like move the camera)? Any other tips on making my game would be greatly appreciated! JSFiddle Here is the code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-demo', { preload: preload, create: create, update: update, render: render }); var player; var starfield; var cursors; var fireButton; var gameOver; var upLedge; var vaRandomUpLedgeSize; var bottomLedge; function preload() { game.load.image('starfield', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAAEACAYAAABcV/9PAAAEWklEQVR42u3ZsW7UShSA4XltxAMgxGPwHHSwRSQaKpR0FCDRQY+AgAzeiccej8fesf0Vn8Llru2zJ//aubnh+bv3P6FUsAQEhIAQEAICASEgBISAQEAIiJYDevv7D1BIQAgIASEgBAQCQkDsKCC/DMNvohEQAkJAICAEhIAQEAgIASEgBAQCQkAICAGBgBAQAkJACAgEhIAQEAICASEgBISAQEAICAEhIBAQAkJACAgBgYAQEAJCQCAgBISAEBAICAEhIAQEAkJACAgBISBLQEAICAEhIBAQAkJACAgEhIAQEAICASEgBISAQEAICAEhIAQEAkJACAgBgYAQEAJCQCAgBISAEBAICAEhIASEgEBACAgBISAQEAJCQAgIBISA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RlF+C+UHwNeMuEwAAAC10RVh0U29mdHdhcmUAYnkuYmxvb2RkeS5jcnlwdG8uaW1hZ2UuUE5HMjRFbmNvZGVyqAZ/7gAAAABJRU5ErkJggg=='); game.load.image('player', 'https://i.imgur.com/JArA3tQ.png'); game.load.image('upLedge', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAACGCAYAAADZ0np4AAAAiklEQVR42u3UsQ2DQAwF0FslPT0jpE+BmIQBaLMDw2QUSpY45IIrTggFQVK94tvds2TJTnN+52npS4ZPU/q36cZH6ZFX+8wJDAaDwWAwGAwGg8FgMBgMBoPBYDAYDAaDwWAwGAwGg8FgMBgM3oej/CJpm3J30pUVHK0DDP4nHCd9JjG8fgP1Swh4Bcd7BZH+S2fyAAAALXRFWHRTb2Z0d2FyZQBieS5ibG9vZGR5LmNyeXB0by5pbWFnZS5QTkcyNEVuY29kZXKoBn/uAAAAAElFTkSuQmCC'); game.load.image('bottomLedge', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAB6CAYAAABQtRgZAAAAgklEQVR42u3TsQmAMBQFwKxib+8I9hbiJA5g6w4O4yiWLhFRUERslAgWF3h5pDmSwA9VUcbUCVPs45MMc3P0Xdoxj+F82PtN6i47GgpNja5b6oTPxvQ6Zk+/4fz07aZQKBQKhUKhUCgUCoVCoVAoFAqFQqFQKBQKhUKhUCj0n+gXawGd+WGo+T+h1gAAAC10RVh0U29mdHdhcmUAYnkuYmxvb2RkeS5jcnlwdG8uaW1hZ2UuUE5HMjRFbmNvZGVyqAZ/7gAAAABJRU5ErkJggg=='); } function create() { // The scrolling starfield background game.physics.startSystem(Phaser.Physics.ARCADE); starfield = game.add.tileSprite(0, 0, 800, 600, 'starfield'); starfield.scale.setTo(1, 2.5); starfield.enableBody = true; // The hero! player = game.add.sprite(50, 400, 'player'); player.anchor.setTo(0.5, 0.5); player.scale.setTo(1.25, 1.5); game.physics.arcade.enable(player); game.physics.enable(player, Phaser.Physics.ARCADE); player.body.gravity.y = 450; player.body.collideWorldBounds = true; upLedge = game.add.sprite(400, 0, 'upLedge'); bottomLedge = game.add.sprite(400, 365, 'bottomLedge'); randomLedgeSize(); upLedge.scale.setTo(1, vaRandomUpLedgeSize); randomLedgeSize(); bottomLedge.scale.setTo(1, vaRandomUpLedgeSize); fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); // And some controls to play the game with cursors = game.input.keyboard.createCursorKeys(); } function update() { // Scroll the background starfield.tilePosition.x -= 2; player.x++; //SPACEBAR if (player.y >= 591.75) { player.y = 591.75; player.x--; } if (fireButton.isDown) { player.body.velocity.y = -250; } game.physics.arcade.collide(player, upLedge); game.physics.arcade.collide(player, bottomLedge); } function render() { } function randomLedgeSize() { vaRandomUpLedgeSize = Math.floor(Math.random() * (3 - 1)) + 1; if (vaRandomUpLedgeSize <= 1.5) { vaRandomUpLedgeSize = 1; } else { vaRandomUpLedgeSize = 2; } } function randomLedgeSizeBot() { vaRandomUpLedgeSize = Math.floor(Math.random() * (3 - 1)) + 1; if (vaRandomUpLedgeSize <= 1.5) { bottomLedge.y = 500; } else { vaRandomUpLedgeSize = 2; } }
×
×
  • Create New...