locojoetive Posted June 15, 2018 Share Posted June 15, 2018 Hello everybody, I am new to Phaser and thought why not start with Phaser 3. My program dynamically changes the rotation of a box and I wanted the collider to rotate as well, but I didn't find how to archive this. var config = { type: Phaser.AUTO, width: 800, height: 600, //window.innerHeight; physics: { default: 'arcade', arcade: { gravity: { y: 300 }, debug: true } }, scene: { preload: preload, create: create, update: update } }; //... function create() { //... blockAU = blocks.create(200, 200, 'block'); //... } function update() { //... if(rotateLeft) blockAU.angle -= 1; else blockAU.angle += 1; blockAU.refreshBody(); //... } I didn't find examples for this, and the API and Docs where pretty confusing. Maybe I am using the wrong terminology when searching. I really hope you can help me with this Link to comment Share on other sites More sharing options...
samme Posted June 15, 2018 Share Posted June 15, 2018 https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#rotation__anchor I can try to improve the docs on this point. locojoetive 1 Link to comment Share on other sites More sharing options...
locojoetive Posted June 16, 2018 Author Share Posted June 16, 2018 Hello samme, Thank you for your fast reply. I replaced block.angle with block.rotation, but get the same results. The link you posted about the rotation of a body says: " It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle." Does this mean it isn't possible to rotate a rectangular body with the Arcade Physics? Link to comment Share on other sites More sharing options...
samme Posted June 17, 2018 Share Posted June 17, 2018 It is not possible, correct. locojoetive 1 Link to comment Share on other sites More sharing options...
locojoetive Posted June 21, 2018 Author Share Posted June 21, 2018 Thank you for the quick response. Link to comment Share on other sites More sharing options...
rudyardcatling Posted August 3, 2019 Share Posted August 3, 2019 hm ... probably not how it's done as i never 'learned' anything but by myself so i tend to go with my way and what works : this.spikes = this.physics.add.staticGroup(); if(leveldata[6]){ console.log(leveldata[6]); tmp = leveldata[6].split('-'); for(let lus=0;lus<tmp.length;lus++){ let spikedat = tmp[lus].split(':'); let spikerot = spikedat[1]; let spikepos = spikedat[0].split(','); console.log(typeof spikerot); switch(spikerot){ case '0': case '2': console.log(spikerot); this.spikes.create(spikepos[0],spikepos[1], 'spikes').setSize(50,34).setOffset(10,0).setAngle(spikerot*90); break; case '1': case '3': this.spikes.create(spikepos[0],spikepos[1], 'spikes').setSize(34,50).setOffset(20,-10).setAngle(spikerot*90);//body.rotation not working or im doing it wrong break; } } } screenshot : screenshot of scene ingame (OGA1 : Oga is the new Crack : get things moving) #opengameart Link to comment Share on other sites More sharing options...
Recommended Posts