Jump to content

When do I need to set game.physics.aracade.enable()?


Recommended Posts



first: I´m new to Phaser. I was reading the tutorial and I dont understand, why you dont have to set "game.physics.arcade.enable()" for platforms("game.physics.arcade.enable(platforms)"?

In the tutorial it´s done for the player("game.physics.arcade.enable(player);") which makes sense. Later on the collision detection "game.physics.arcade.collide(player, platforms);" however looks for collisions between the player and the platforms. Shouldn´t playtforms be an Arcade Physics body as well? In the tutorial on player is getting up with it.

Thank you! :)

Link to comment
Share on other sites


It's because the Group in which all of the platforms are added is physics enabled itself, which is passed on to all children:

    //  The platforms group contains the ground and the 2 ledges we can jump on
    platforms = game.add.group();

    //  We will enable physics for any object that is created in this group
    platforms.enableBody = true;


Link to comment
Share on other sites

Hi rich,


that makes sense - thank you! I have another question(I hope it´s ok that I´,ll put it in here).


Let´s say I have the following code:

var game = new Phaser.Game(800, 600, Phaser.AUTO, "",
		preload: preload,
		create: create,
		update: update

function preload() {
	game.load.image("ground", "assets/ground.png")
	game.load.image("towerAtt", "assets/towerAtt.png")

function create() {
	groundField = game.add.group();
	groundField.enablebody = true;
	ground = groundField.create(0, 0, "ground")
	ground.scale.setTo(game.width/ground.width, game.height/ground.height)
	//tower = game.add.image(0, 0, "towerAtt")

function update() {



Let´s say I want to create something(a tower) when a specific event happens(for example the user clicking a button). How would I do that?


I´ll try to explain my thoughts and problems: since I dont want any towers to show up(place one tower after a user interaction), I cant paste

tower = game.add.image(0, 0, "towerAtt")

this in the create function, since it will get created(and shown), right?

What would be a short solution to it?


Thank you! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...