Hey.
What are our chances to get anchor points to sprites? I arranged my scene using some sprites as containers for underlying sprites. Scaling the container scales children too. But scaling goes into the direction of the container sprites' left top corner - which apparently can't be changed. Anchor point seems to be a chance to get rid of this behaviour
.
Greetings
Sebastian
Comments
For example @Niicodemus uses his own hack for dealing with scaling:
http://www.giderosmobile.com/forum/discussion/2715/camera-class-with-kinetics-and-pinch-to-zoom#Item_7
But there are some more general usage addons as GiderosCodingEasy:
https://github.com/ar2rsawseen/GiderosCodingEasy
Stack trace:
...
./lib/sprite.lua:125: in function '?'
./lib/sprite.lua:125: in function '?'
./lib/sprite.lua:125: in function '?'
./lib/sprite.lua:125: in function '?'
lib/sprite.lua:125: in function 'addEventListener'
lib/scene_manager.lua:253: in function 'init'
[string "property.lua"]:52: in function '__new'
[string "property.lua"]:59: in function 'new'
main.lua:4: in main chunk
Files:
https://github.com/ar2rsawseen/GiderosCodingEasy/blob/master/GiderosCodingEasy.lua
https://github.com/gideros/Scene-Manager/blob/master/scenemanager.lua
I'll have a closer look at it. Maybe the solution is more obvious to you than to me ...
Greetings
Sebastian
It does not happen every time, only in some specific situations, but I can't figure which now
Does your project work without GiderosCodingEasy?
It seems that you can't add your scene as a child of SceneManager?
Is your scene inherited from Sprite?
As in like this:
Yes, without GCE the code works fine.
(Btw: The GCE example code works fine on my machine.)
If you don't exclude it, then it is executed twice and creates some different and unpredictable magic
https://github.com/nshafer/AnchorSprite
Thanks,
Nathan Shafer
Likes: SinisterSoft, vitalitymobile
However, I find that nearly every time I want to use setAnchorPoint() I actually want the object to stay in the same position. This is probably because I'm loading scenes from SVG and the initial positions are set relative to top left. However, I imagine this could be useful in many other cases too.
I've written a method, resetAnchorPoint() that does this for simple cases i.e. if the Sprite is not rotated. I wonder if you'd consider adding a more general case to your AnchorSprite module. This is my version:
Likes: vitalitymobile
Nathan Shafer
Often, especially when applying animations, I need the anchor point to be at the centre of the object - which is where AnchorSprite comes in. Currently, using setAnchorPoint() will cause the objects to move from their SVG positions, which is obviously not what I want - hence my use of resetAnchorPoint() above.
I thought this might be quite a common activity but, if it's not, don't worry about it and I'll just add resetAnchorPoint() to my BhHelpers library.
best regards
Likes: vitalitymobile