cityrock Posted November 5, 2013 Share Posted November 5, 2013 Hello,I am very very new to phaser and just started playing around with it.I am trying to find a way in which i can rotate (using rotation, angle or any other method can be advised) the world of a game in which the center point of rotation is the center of the camera, and not position 0,0 of the world itself.This means the center point for rotation is dynamic and based on the center point of the current camera.Is it possible to do with phaser? I believe I am looking for a way to offset the point of rotation for the world object of the game.Thanks in advanceEli Link to comment Share on other sites More sharing options...
Mike Posted November 5, 2013 Share Posted November 5, 2013 Just to be sure is this your goal: http://www.tonypa.pri.ee/tbw/tut21.html and for the moment I don't have the answer but I'm curious too. plicatibu 1 Link to comment Share on other sites More sharing options...
cityrock Posted November 5, 2013 Author Share Posted November 5, 2013 Exactly what i am looking for. Link to comment Share on other sites More sharing options...
cityrock Posted November 7, 2013 Author Share Posted November 7, 2013 Anyone know if this is possible? change the anchor position of the world for rotation?Thanks again,Eli Link to comment Share on other sites More sharing options...
Taleforge Posted March 7, 2014 Share Posted March 7, 2014 Hi, I want to do something very similar. Is there any way to archive this? Best solution would be a rotation-property in the camera object! Thanks in advance Link to comment Share on other sites More sharing options...
Taleforge Posted March 7, 2014 Share Posted March 7, 2014 I found a way to rotate the camera around a given point:game.camera.displayObject.pivot.x = game.camera.view.x + game.camera.view.width/2;game.camera.displayObject.pivot.y = game.camera.view.y + game.camera.view.height/2;game.camera.displayObject.rotation = Math.PI/4; // place your rotation here I sill have some trouble now: When i place my camera to the player its not working anymore:game.camera.focusOnXY(player.x, player.y);I think the pivot-Point has some effect on that positioning ... but Iam not sure how to calculate the right position. Link to comment Share on other sites More sharing options...
rantt Posted April 8, 2014 Share Posted April 8, 2014 I'd also like to know if anyone has had any luck with this. I've been able to rotate the tilemap around my player character, but the collisions stay where they were when the map was initially created. Link to comment Share on other sites More sharing options...
Leedow Posted April 27, 2014 Share Posted April 27, 2014 I've tried rotating the camera and it works if I set the bounds of world to negative startvalues. This is in order to offset the origin of camera, etc. Without this the camera keeps rotating at [0,0] (top left) of canvas. There are a few things that makes this a bad choice. First of all the "fixedToCamera" does not work, since the camera is in fact rotating. In essence all "fixedToCamera"-objects become part of the world. Also, setting camera.displayObject.pivot breaks the "follow" setting of the camera. These are my findings, perhaps it's not broken, I'm just not using it correctly. I hope there is another way, like... rotating world, game, stage or something like that. Link to comment Share on other sites More sharing options...
Leedow Posted April 28, 2014 Share Posted April 28, 2014 I hope there is another way, like... rotating world, game, stage or something like that. Answering myself on this one. I went through all of the examples on the Phaser example page and I found EXACTLY what I was looking for.http://examples.phaser.io/_site/view_full.html?d=input&f=cursor+key+movement.js&t=cursor%20key%20movement In the example the world is rotating, not the camera.I sure hope I will be able to setup all my configurations without limitations this way. For instance specifying some kind of origin of the rotation. According to what I read earlier about rotation on the World class, it always rotates out of [0,0] which is not what I want, perhaps there is a way to modify this anyway.Gonna try this out tomorrow or day after tomorrow. Let's hope for the best! Link to comment Share on other sites More sharing options...
Leedow Posted April 29, 2014 Share Posted April 29, 2014 Gonna try this out tomorrow or day after tomorrow. Let's hope for the best! Initial findings are not great.The world does rotate, yay! but...It's a bit of a hassle to reset bounds every time the player moves to set the origin at the center of the screen/camera where the player is.Also, the bounds are quite useful and I'm not sure that the game would be optimal if the bounds keep changing.Objects that have the property "fixedToCamera" set to true, does not appear to work as intended, they rotate with the world. I'll have to keep at it I guess. Link to comment Share on other sites More sharing options...
luckylooke Posted August 21, 2014 Share Posted August 21, 2014 Hi, I want to do something very similar. Is there any way to archive this? Best solution would be a rotation-property in the camera object! Thanks in advance +1 Link to comment Share on other sites More sharing options...
CtlAltDel Posted August 21, 2014 Share Posted August 21, 2014 See this topic for a possible solution: http://www.html5gamedevs.com/topic/6414-rotate-camera/#entry38295 Link to comment Share on other sites More sharing options...
luckylooke Posted August 21, 2014 Share Posted August 21, 2014 (edited) See this topic for a possible solution: http://www.html5gamedevs.com/topic/6414-rotate-camera/#entry38295 See my post there, I cannot make that snipped work, instead of rotation it moves left and right. Demo: http://jsfiddle.net/luckylooke/uL37am1h/4/ Ok I didnt notice SHIFT key must be pressed Edited August 21, 2014 by luckylooke Link to comment Share on other sites More sharing options...
Recommended Posts