Just familiarizing with Phaser and playing with Arcade physics I was wondering how to get going with just generic shapes or geometry or blank image that doesn’t result in an ‘x’ or black square…
https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Factory.html
for example, say I want to just create two rectangles one is blue one is red.
if you had preloaded an image texture, in update you can do:
this.physics.add.image(400, 300, 'myImage')
but i just want to do something like:
this.physics.add.image(400, 300, '0x0000ff') //< the color blue
and then one for red and so forth; in other words: how do I quickly get a solid color shape or polygon for prototyping in there. I don’t want to load a texture each time I want to experiment with a new game object; just need shape & solid color.
alternatively, is it possible to extend Geom objects with Arcade Physics ? Something like this:
let rect = new Phaser.Geom.Rectangle(250, 200, 300, 200)
let graphics = this.add.graphics({ fillStyle: { color: 0x0000ff } })
graphics.fillRectShape(rect)
let rectWithPhysics = this.physics.extend(rect)
rectWithPhysics.setCollideWorldBounds(true)
rectWithPhysics.setVelocityX(50)