Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

rotate group of object relative to center without physic
Started by arash45654 Jul 14 2017 07:31 AM

- - - - -
5 replies to this topic
rotate rotation center group display group anchor

Best Answer roaminggamer , 14 July 2017 - 08:26 AM

local gp = display.newGroup( )
gp.x = display.contentCenterX
gp.y = display.contentCenterY
local line1 =display.newLine( gp, -150,-150,150,150 )
line1.strokeWidth = 2
local line2 =display.newLine( gp, 150,-150,-150,150 )
line2.strokeWidth = 2
display.newRect( gp, 0, 0, 40, 40)
transition.to( gp, { rotation = 360, time = 5000 }) 

Try this code to see what I mean by my earlier suggestion

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

arash45654

[GLOBAL: userInfoPane.html]
arash45654
  • Observer

  • 20 posts
  • Corona SDK

Hi,

i want to rotate the objects in a display group around center point

assume this code:
 

local gp=display.newGroup( )
local line1=display.newLine( 1,1,100,100 )
local line2=display.newLine( 100,0,0,100 )
gp:insert( line1 )
gp:insert( line2 )
gp.anchorX=.5
gp.anchorY=.5
gp:rotate( 90 )

but this group does not rotate relative to center point.I want to move group relative to red point like below image :

Screen%20Shot%202017-07-14%20at%207.56.0



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,589 posts
  • Corona SDK

Do display groups have anchors? For some reason I think not.

 

**UPDATE** I should have asked, "Do they respect anchors."  By default, the answer is, "No."


Edited by roaminggamer, 14 July 2017 - 08:28 AM.


[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,589 posts
  • Corona SDK

Just place 'centered' objects at 0,0 in the group and move the group to the center of the screen.

Then rotate

[TOPIC: post.html]
#4

arashmobileboy

[GLOBAL: userInfoPane.html]
arashmobileboy
  • Observer

  • 24 posts
  • Corona SDK

Do display groups have anchors? For some reason I think not.

no they have default anchor(0.5)

 

Just place 'centered' objects at 0,0 in the group and move the group to the center of the screen.

Then rotate

I  did not get what you mean

Thanks



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,589 posts
  • Corona SDK

Regardless of whether they have a value, groups do not respect anchors.

[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,589 posts
  • Corona SDK

  Best Answer

local gp = display.newGroup( )
gp.x = display.contentCenterX
gp.y = display.contentCenterY
local line1 =display.newLine( gp, -150,-150,150,150 )
line1.strokeWidth = 2
local line2 =display.newLine( gp, 150,-150,-150,150 )
line2.strokeWidth = 2
display.newRect( gp, 0, 0, 40, 40)
transition.to( gp, { rotation = 360, time = 5000 }) 

Try this code to see what I mean by my earlier suggestion




[topic_controls]
[/topic_controls]