Jump to content

rotation and angles


cityrock
 Share

Recommended Posts

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 advance

Eli

Link to comment
Share on other sites

  • 3 months later...

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

  • 1 month later...
  • 3 weeks later...

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

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

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

  • 3 months later...

 

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 :D

Edited by luckylooke
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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