Rotate physics with map/object *issue* (plug and play code included)

7 replies [Last post]
nicholasclayg
User offline. Last seen 5 years 44 weeks ago. Offline
Joined: 16 May 2011

I searched, and searched. Only thing I saw was on lime for map.rotation
I have lime, but I am developing natively in Corona first to get a grip on things

First, load this code into Corona and launch it

The box will start falling, tap the screen to rotate.

...assuming you have seen the demo run

Note how the box continues bouncing down the 2 stair steps even though the objects have rotated clockwise.

I've been trying to figure out how to somehow group physics bodies? Is it possible?

I know NayGames was looking at something like this but on LIME which I think there is a limitation, so I'm trying it in just corona.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--Hide Status Bar
display.setStatusBar(display.HiddenStatusBar)
 
--load physics
 
local physics = require("physics")
physics.start()
--DRAW MODE
--"hybrid" "debug" "normal"
physics.setDrawMode( "hybrid" )
 
-- Scale set to 60, cuz I felt like it :)_
physics.setScale( 60 )
 
--Set only Y gravity and 0 to X
 
physics.setGravity( 0, 2 )
 
--Load Audio
 
--template for my bg audio
local soundtrack = audio.loadStream("media/insertsoundtrackhere.mp3")
 
--make audio loop infinitely using -1
audio.play(soundtrack, {loops=-1})
 
 
--Load images
 
--(X position, Y position, X size, Y size)
 
local back = display.newRect(0, 0 , 700, 700)
back:setFillColor(100, 210, 33)
 
local rect1 = display.newRect( 110, 250, 100, 100 )
rect1:setFillColor(255,255,255)
physics.addBody( rect1,"static", { friction=3, bounce=0.3, isGround = true } )
 
 
local rect2 = display.newRect( 210, 150, 300, 100 )
rect2:setFillColor(255,0,255)
physics.addBody( rect2,"static", { friction=3, bounce=0.3, isGround = true } )
 
local box = display.newRect(20,20,50,50  )
box.x = 200; box.y = 20
box:setFillColor(100,50,111)
physics.addBody( box, { density=1.0, friction=10, bounce=0.2} )
 
 
--Set the reference to the interface and master groups
 
interfaceGroup = display.newGroup()
interfaceGroup.xReference = 2000
interfaceGroup.yReference = 2000
 
--Place images into groups (Layer them so what goes in back goes 1st
--Take the local object we created with a variable and insert into the Interface group we created earlier
interfaceGroup:insert(back)
interfaceGroup:insert(rect1)
interfaceGroup:insert(rect2)
 
--the x and yReference are referenced from 0 meaning upper left of the device. 
--Now we are taking the interfaceGroup, and inserting into the MasterGroup
masterGroup = display.newGroup()
masterGroup.xReference = 150
masterGroup.yReference = 150
masterGroup:insert(interfaceGroup)
--masterGroup.x and .y reference - where the center of the rotation will be on screen
 
--+++++EXPERIMENTAL PHYSICS GROUP LOCK CODE
 
--Place code to rotate map and physics here :)...thats if and when it's possible
 
 
----+++++EXPERIMENTAL PHYSICS GROUP LOCK CODE+++++++++++++++++++
 
-- Touch Response
 
local function buttonActionR()
transition.to(masterGroup, { rotation=90, time=500, delay=0 } )
end
 
masterGroup:addEventListener( "touch", buttonActionR )

Replies

calebr2048
User offline. Last seen 1 year 5 weeks ago. Offline
Joined: 25 Jan 2011

I'm not on my dev machine so I can't run your example but are you trying to rotate a group and have gravity rotate with it? You just need to change the direction of gravity when you rotate the group by switching it from 0,2 to -2,0 (assuming the group is rotating clockwise).

nicholasclayg
User offline. Last seen 5 years 44 weeks ago. Offline
Joined: 16 May 2011

@calebr2048

I am not messing with gravity, I want it to always be going down.

What I am trying to accomplish (you have to run the sample to really see what I am saying) is to rotate the physics bodies with the object.

When the draw mode is set to hybrid, the objects rotate and orientation is correct, but the physics bodies attached to those objects do not rotate.

I want the objects + physic body properties to rotate on screen but leave gravity as it is.

-ng

calebr2048
User offline. Last seen 1 year 5 weeks ago. Offline
Joined: 25 Jan 2011

I ran your sample and now I understand. This is an issue I have read about on the forums several times and from what I can tell it has not been resolved. I don't know if there is a bug report for this assuming that it is a bug and not a limitation of box2D.

nicholasclayg
User offline. Last seen 5 years 44 weeks ago. Offline
Joined: 16 May 2011

Yea, this is VERY disappointing. I came up with a concept for a game and it depends on this feature.

I've had to drop it for now, as it seems I am not the only one who's having issues with this.

If someone knows how to group the physics bodies with the associated objects i'm all ears.

I'm easy going though, since I have found Corona, I have now 33 game ideas that are pretty unique, so I'l going down my top 5 that I want to make.

The above was my #1, but I guess i'll either have just wait it out, or have to learn something else or something.

Hmm?

nicholasclayg
User offline. Last seen 5 years 44 weeks ago. Offline
Joined: 16 May 2011

Bumpity bump bump.

I would love to have this feature!

-ng

tsuriyathep
User offline. Last seen 5 years 21 weeks ago. Offline
Joined: 21 Oct 2011

Does anyone know if this issue has been resolved yet? Its been more than 6 months, is it even being considered for being fixed?

justfunk
User offline. Last seen 3 years 39 weeks ago. Offline
Joined: 23 Jan 2011

i have the same problem.... all know about it issue, but coronas team is not going to correct their mistakes. I stopped the development of the game and moved to another game platform

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.