Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
help with a "Rotation" — Gideros Forum

help with a "Rotation"

Bar_Duck13Bar_Duck13 Member
edited August 2012 in General questions
I write through a translator.
"Sprite:getRotation" method rotates the sprite relative to the point (0,0). How to rotate a sprite in an arbitrary point?

Comments

  • setAnchorPoint(x, y)

    Parameters:
    x: (number) The x coordinate of anchor point. Usually between [0, 1].
    y: (number) The y coordinate of anchor point. Usually between [0, 1].

    hope it help.
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • NascodeNascode Guru
    edited August 2012
    @GregBUG
    is Sprite:setAnchorPoint(x,y) has been implemented officially? I thought only Bitmap:setAnchorPoint(x,y) in the official API right now.

    But worry not @jack0088 has made addition for Sprite class for handling anchor point http://giderosmobile.com/forum/discussion/1502/setanchorpoint-for-sprites-shapes-and-all-of-your-classes#Item_1

    However if you love the matrix to do hardcore transformation, then try Sprite:setMatrix
    have fun with our games~
    http://www.nightspade.com
  • setAnchorPoint(x, y)

    Parameters:
    x: (number) The x coordinate of anchor point. Usually between [0, 1].
    y: (number) The y coordinate of anchor point. Usually between [0, 1].

    hope it help.
    Thanks!!
    I have used this solution:


    dot = Bitmap.new(Texture.new("OB.PNG")) --32x32
    dot:setPosition(-16, -16)

    group1 = Sprite.new()
    group1:addChild(dot)
    stage:addChild(group1)

    group1:setRotation(45)--Rotate about centre
  • for center the rotation point you should use

    dot:setPosition(.5, .5)
    :D
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • @GregBUG meant
    dot:setAnchorPoint(0.5,0.5)
    setAnchorPoint accepts relative coefficient form 0 to 1, where 0 is the left/top side, 0.5 is a center and 1 is the right/bottom side (depending on x or y axis)
  • @GregBUG meant
    dot:setAnchorPoint(0.5,0.5)
    setAnchorPoint accepts relative coefficient form 0 to 1, where 0 is the left/top side, 0.5 is a center and 1 is the right/bottom side (depending on x or y axis)
    exactly ...
    .... ;)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Bar_Duck13Bar_Duck13 Member
    edited August 2012
    Thanks, guys.
    I asked a question simpler, but my thoughts were deeper.
    For example, I have a structure of objects:
    stage --Sprite
    ___anylayer --Sprite
    ______anyBitmap1 --Bitmap
    ______anyBitmap2 --Bitmap
    ______anyBitmap3 --Bitmap

    I wanted to turn the whole sprite "anylayer" relative to the point, but it is impossible now. Thank you again.
  • ar2rsawseenar2rsawseen Maintainer
    edited August 2012
    As @Nascode mentioned:

    But worry not @jack0088 has made addition for Sprite class for handling anchor point http://giderosmobile.com/forum/discussion/1502/setanchorpoint-for-sprites-shapes-and-all-of-your-classes#Item_1
    it is possible due to the power of community ;)



  • it is possible due to the power of community ;)

    There is linked file that i can't download. And i don't know, how to use it.
  • Hmm,
    usually you can't download file if you are not logged in. Could you check ii when you visit that thread. Does it show that you are logged in, when trying to download file?

    About usage:
    Simply include it in your project init.lua file (create one if you don't have it) and all your Sprite's will have setAnchorPoint methods
  • MellsMells Guru
    edited September 2012
    Edit > Submitted directly in my own discussion.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
Sign In or Register to comment.