Jump to content

Search the Community

Showing results for tags 'plateforms'.

  • 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. Hi everyone, My apologies for my bad english, i'm french Here's my code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Phaser</title> <script type="text/javascript" src="js/phaser.js"></script> <style type="text/css"> body { margin: 0; } </style></head><body><div id="game"></div><script type="text/javascript">var game = new Phaser.Game(800, 600, Phaser.AUTO, 'game', { preload: preload, create: create, update: update });function preload() { this.load.image('player', 'assets/j1.png'); this.load.image('plate', 'assets/bloc.png');}function create() { game.physics.startSystem(Phaser.Physics.ARCADE); this.stage.backgroundColor = '#7e7e7e'; player = new Player(game, 20, 20); game.add.existing(player); game.time.events.loop(Phaser.Timer.SECOND * 1.25, genPlateforms); //Generation de plateforme //FPS game.time.advancedTiming = true; fpsText = game.add.text( 20, 20, '', { font: '16px Arial', fill: '#ffffff' } ); }function update() { if (game.time.fps !== 0) { fpsText.setText(game.time.fps + ' FPS'); }}var genPlateforms = function(){ random = game.rnd.integerInRange(-50, 50); //Valeur Random plateforms = new Plateforms(game, game.width , game.height / 2 + random); //Plateforms a hauteur random depuis le milieu game.add.existing(plateforms);}// Player contructorvar Player = function(game, x, y, frame) { Phaser.Sprite.call(this, game, x, y, 'player', frame); this.game.physics.arcade.enableBody(this); this.body.bounce.y = 0.1 ; this.body.gravity.y = 600; this.body.collideWorldBounds = true; //Collision avec les bords cursors = this.game.input.keyboard.createCursorKeys();};Player.prototype = Object.create(Phaser.Sprite.prototype);Player.prototype.constructor = Player;Player.prototype.update = function() {this.body.velocity.x = 0;if (cursors.left.isDown) { this.body.velocity.x = -500; }else if (cursors.right.isDown) { this.body.velocity.x = 500; }if (cursors.up.isDown)// && this.body.blocked.down) { this.body.velocity.y = -400; }};//Plateforms Constructorvar Plateforms = function(game, x, y, frame) { Phaser.Sprite.call(this, game, x, y, 'plate', frame); this.anchor.setTo(0.5,0.5); this.game.physics.arcade.enableBody(this); this.body.immovable = true; this.body.velocity.x = -350; this.checkWorldBounds = true; this.outOfBoundsKill = true; //Detruire l'objet non visible};Plateforms.prototype = Object.create(Phaser.Sprite.prototype);Plateforms.prototype.constructor = Plateforms;Plateforms.prototype.update = function() {game.physics.arcade.collide(player, plateforms); //Collision entre le player et les plateformes};</script></body></html>this is what you get: So i split the screen by 3 zone to explain my problem: Zone 3: The player is able to jump on the plateforms, it work perfectly. Zone 2: The player don't collide with the top of the plateforms, Zone 1: The player don't collide with the plateforms I don't know why. I already try it with the yeoman generator, same result, so i'm sure the problem is from the code(also because i'm a newbie in JS).
×
×
  • Create New...