Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Movieclip & AnchorPoints — Gideros Forum

Movieclip & AnchorPoints

NinjadoodleNinjadoodle Member
edited October 2015 in General questions
Hi guys

When adding anchor points to movie clips, do they have to be added one by one fro each frame (like below)?
local frames = {}
 
	frames[1] = Bitmap.new(pack1:getTextureRegion("lightbulbAnim0001.png", true))
	frames[2] = Bitmap.new(pack1:getTextureRegion("lightbulbAnim0002.png", true))
	frames[3] = Bitmap.new(pack1:getTextureRegion("lightbulbAnim0003.png", true))
 
	frames[1]:setAnchorPoint(0.5, 0)
	frames[2]:setAnchorPoint(0.5, 0)
	frames[3]:setAnchorPoint(0.5, 0)
Thank you in advance!

Comments

  • piepie Member
    @Ninjadoodle I think so, since MovieClip is Sprite based, and Sprite natively doesn't support setAnchorPoint (while Bitmap does).
    However in giderosCodingEasy there is a Sprite:setAnchorPoint() method that should enable this feature on MC too :)
  • if all of your bitmaps are of the same size then using setAnchorPosition (note that it's not Point but Position) should work:

    myMc:setAnchorPosition(myMc:getWidth()/2,myMc:getHeight()/2)

    does it?
  • NinjadoodleNinjadoodle Member
    edited October 2015
    Hi @pie

    Thanks for the reply!

    I think I am using giderosCodingEasy (its in my project folder), because I can set a anchor points for sprites.

    It however doesn't seem to work with mc.
  • Hi @keszegh

    Ahh, that world make sense, since myMc is kind of like a container for all the frames.

    Thanks for the tips!
  • Hi @keszegh

    I've tried ...

    myMc:setAnchorPosition(myMc:getWidth()/2,myMc:getHeight()/2)

    and also

    myMc:setAnchorPoint(myMc:getWidth()/2,myMc:getHeight()/2)

    but neither one works.
  • keszeghkeszegh Member
    edited October 2015 Accepted Answer
    it seems to work for me after a quick test, remember to call
    myMc:setAnchorPosition(myMc:getWidth()/2,myMc:getHeight()/2)
    before calling any setscale etc things.
    and if you want to have "frames[1]:setAnchorPoint(0.5, 0)" effect then of course do
    myMc:setAnchorPosition(myMc:getWidth()/2,0)

    but all in all
    for key,value in pairs(frames) 
    frames[key]:setAnchorPoint(0.5, 0)
    end
    is not that much of a hassle, so you can stick with it if that works.
  • Thank you, this helps a lot!

    Using the for loop, will be the easiest in my case :)
Sign In or Register to comment.