Jump to content

Search the Community

Showing results for tags 'arcade.physics.collide'.

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

  1. https://play.idevgames.co.uk/game/catch-the-fish/ You play for a very greedy bear who is ready to fish until his energy is over. When you catch the right fish, some of the energy is restored, but over time it will end. Your task is to score as many points as possible, balancing between the more valuable fish and more nutritious. It appears randomly and jumps in a random direction.
  2. Soloshadow

    collision

    Hi everyone, I am pretty new to phaser but I am working on an endless runner game and I would like my player to be able to jump on top of platforms. BUt everytime I try to jump on one my character just pass through it like it isn't even there. This is the code to my platform (I am working in typescript if it matters) class Platform extends Phaser.Sprite{ private platform; constructor(g: Phaser.Game, x: number, y: number){ super(g,x,y,"platform",0); this.platform = this.game.add.sprite(x,y,'platform') this.platform.scale.setTo(5, 2); //this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.physics.enable(this.platform, Phaser.Physics.ARCADE); //this.platform.body.allowGravity = false; this.platform.body.immovable = true; } public update(){ this.platform.body.velocity.x -= 0.5; /* if(this.platform.body.velocity.x < -(this.platform.width)){ this.platform.body.velocity.x = this.game.width; console.log("this"); } */ } } This is the player class. I didn't work on this. A team member did this class Player extends Phaser.Sprite{ //create a subclass voor Phaser.Sprite private playerSprite = this.game.add.sprite(0, 0, 'player'); //de url van de sprite staat in global.ts //gravity private jumpTimer = 0; private jump: Phaser.Key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); //mapping keys private jumpAlt: Phaser.Key = this.game.input.keyboard.addKey(Phaser.Keyboard.UP); private slide: Phaser.Key = this.game.input.keyboard.addKey(Phaser.Keyboard.CONTROL); private slideAlt: Phaser.Key = this.game.input.keyboard.addKey(Phaser.Keyboard.DOWN); public speed:number = 30; private score:number = 0; constructor(game:Phaser.Game, x:number, y:number){ //word ook sprite aangemaakt??? super(game,x,y,"player",0); //Een typescript functie voor subclasses( https://tutorialstown.com/super-keyword-with-constructor-in-typescript/ ) //geen verwarring meer bij this.y en this.playerSprite.y this.playerSprite.x = x; this.playerSprite.y = y; //spritegrootte this.playerSprite.width = 100; this.playerSprite.height = 144; //muisklik (op telefoon is dat je vinger) this.playerSprite.inputEnabled = true; //this.playerSprite.events.onInputDown.add(Player.prototype.jump, this); this.jump.onDown.add(Player.prototype.goUp, this); //Voer functies uit op basis van input this.jumpAlt.onDown.add(Player.prototype.goUp, this); this.slide.onDown.add(Player.prototype.goDown, this); this.slideAlt.onDown.add(Player.prototype.goDown, this); this.anchor.set(0.5,0.5); //verander de anchor point voor de sprite this.scale.set(0, 0.2); //jumping (gravity) this.game.physics.startSystem(Phaser.Physics.ARCADE); //this.game.physics.arcade.gravity.y = 250; this.game.physics.arcade.enable(this.playerSprite); this.playerSprite.body.collideWorldBounds = true; //this.game.physics.enable(this.playerSprite, Phaser.Physics.ARCADE); this.playerSprite.body.gravity. y = 250; this.playerSprite.body.bounce.y = 0.15; this.playerSprite.body.collideWorldBounds = true; console.log("player setup"); } private doJump(velocity:number) { if (this.jump.isDown && this.playerSprite.body.onFloor() && this.game.time.now > this.jumpTimer || this.jumpAlt.isDown && this.playerSprite.body.onFloor() && this.game.time.now > this.jumpTimer) { this.playerSprite.body.velocity.y = velocity; this.jumpTimer = this.game.time.now + 750; console.log("jumping"); } } And in the update function in the gameplay state we added this.game.physics.arcade.collide(this.player, this.platform); this.player and this.platform is the name of the instance that was created in the gameplay state
×
×
  • Create New...