Hi, I'm trying to find a good way to rotate the screen around it's center, no matter where in the stage it's focused.
The screen follows the player character "ball", as I followed this tutorial:
http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-MoveNow, I tried to implement the camera rotating feature like this:
self:setRotation(-self.ball:getRotation())
Which does work fine, but the axis of the rotation is obviously not in the center of screen. I tried to set the anchorpoint to "self", but that gives me an error:main.lua:275: attempt to call method 'setAnchorPoint' (a nil value).
What would be the best way to implement this?
Comments
You can try downloading GiderosCodingEasy from here: https://github.com/ar2rsawseen/GiderosCodingEasy
include init.lua and GiderosCodingEasy.lua in your project, and exclude GiderosCodingEasy.lua from execution, by right clicking on it and selecting Exclude from Execution.
Now you will be able to use anchorpoints on any Sprite and Sprite inherited element.
So go to function scene:onEnterFrame() in Camera Move example project and comment the lines, that set the offset there, because you will need to set your own values
I've attached the modified example project here
P.S just don't look too long on the example, it'll make you feel dizzy
Likes: Karriz
This doesn't seem to happen in the example you added, only in my project, but it has more stuff in it so maybe it's a performance issue? Could changing the self.world:step values help?
I don't suppose it would be an issue with using 2012.09.9 ?