sprite moves through static walls help

Hi,
forgive my question but having played around with this for a couple of hours I wonder if someone would be so kind as to help out ?

I have a bird sprite which is displayed to screen at a fixed x,y.
I have a parallax scrolling background.
I have used the joystick.ui for control.

All the above is working fine, there are NO physics applied to any of it yet.
The bird does exactly as it should.

I set up a 1px invisible rect on the ground to test.
My sprite just flys straight through it, obviously I then added to physics to my sprite “dynamic”.
The bird will now fall from its initial x.y position and land on the floor, it will then fly fine using the joystick control.
Once any input has ceased through the joystick it falls back to the ground.

I need the bird to stay at the position it was last at once joystick input has ceased, and for it to be at the original x.y at start up.
If I remove “dynamic” physics on the bird it works great but still flys through the ground.
What am I missing here???

thanks [import]uid: 127675 topic_id: 30008 reply_id: 330008[/import]

set gravity to 0? [import]uid: 160496 topic_id: 30008 reply_id: 120191[/import]

Hi MIke,
thanks for the reply,

If I set gravity to “0” it acts globally as we know, the bird sprite falls to the ground when I assign the physics body to the sprite"dynamic"
I thought maybe I could not add any physics to the bird whatsoever and maybe add an invisible shape to the sprite in order detect collisions.
This seems to be a hack though ? I am not sure how it is done in the real world ?

Any more thoughts guys? [import]uid: 127675 topic_id: 30008 reply_id: 120192[/import]

Ok, I know this is not really my ‘forum area’, but I’ve made a solution to that:

http://developer.coronalabs.com/code/golem-gravity

You could add gravity to everything but the bird, and then that might work.

quinc [import]uid: 147322 topic_id: 30008 reply_id: 120195[/import]

@quinc
if i add gravity to everything but the bird, surely the bird would still be able to fly off the screen as the invisible rectangles at 1px(ala balloon game) would have physics and the bird none?
There has to be a way of keeping a bird in the air without it able to cross the bounds of the visible screen.
If I add dynamic physics to the bird it is no problem, but then the bird takes on default gravity and falls to the base object.
I will try to find an example of something similar unless you guys no of something?

Cheers [import]uid: 127675 topic_id: 30008 reply_id: 120196[/import]

you could apply the force to bird that is opposite to gravity [import]uid: 160496 topic_id: 30008 reply_id: 120198[/import]

I don’t think you get me. With the library I gave you the link to, you use it by setting the gravity to 0 and then adding the gravity to each thing individually. That means you can set the bird to a dynamic physics shape and just not add gravity (from the module) to it. Then add gravity to everything else and there you go. You have one bird that does not fall under gravity (but is still dynamic) and everything else that does fall under gravity.

quinc [import]uid: 147322 topic_id: 30008 reply_id: 120200[/import]

@quinc,
Apologies for not understanding, Iam with you now.
Sounds promising.
I’ve been attempting to find an app with what I propose but can only find mainly objects and sprite using what I figure is impulse and angular physics to propel them.
I was all for canning the project, then considered the invisible rect collision filters with sensor.
I hope to try what you suggest asap.
Thankyou [import]uid: 127675 topic_id: 30008 reply_id: 120208[/import]

@quinc,

hi, I have tried to implement gg into a very simple project.i.e. a ball only on screen in order to understand your library.
I can not for life of me get physics applied to the object ?
I am just getting REs in the module as force is applied, line 25.
Would you be so kind as to provide some simple example code in a main.lua on calling and implementing the the module on say a ball or rect?
Apologies if this a simple question but I am calling the module as normal but struggling.

thank you Quinc [import]uid: 127675 topic_id: 30008 reply_id: 120241[/import]

I’ll add it to the library. You can just use the earlier link to get to it. [import]uid: 147322 topic_id: 30008 reply_id: 120244[/import]

@quinc,

oops, forgot to un comment the physics body to the bird, I am an idiot.
Looking good now, time play.

thankyou [import]uid: 127675 topic_id: 30008 reply_id: 120245[/import]

set gravity to 0? [import]uid: 160496 topic_id: 30008 reply_id: 120191[/import]

Hi MIke,
thanks for the reply,

If I set gravity to “0” it acts globally as we know, the bird sprite falls to the ground when I assign the physics body to the sprite"dynamic"
I thought maybe I could not add any physics to the bird whatsoever and maybe add an invisible shape to the sprite in order detect collisions.
This seems to be a hack though ? I am not sure how it is done in the real world ?

Any more thoughts guys? [import]uid: 127675 topic_id: 30008 reply_id: 120192[/import]

Ok, I know this is not really my ‘forum area’, but I’ve made a solution to that:

http://developer.coronalabs.com/code/golem-gravity

You could add gravity to everything but the bird, and then that might work.

quinc [import]uid: 147322 topic_id: 30008 reply_id: 120195[/import]

@quinc
if i add gravity to everything but the bird, surely the bird would still be able to fly off the screen as the invisible rectangles at 1px(ala balloon game) would have physics and the bird none?
There has to be a way of keeping a bird in the air without it able to cross the bounds of the visible screen.
If I add dynamic physics to the bird it is no problem, but then the bird takes on default gravity and falls to the base object.
I will try to find an example of something similar unless you guys no of something?

Cheers [import]uid: 127675 topic_id: 30008 reply_id: 120196[/import]

you could apply the force to bird that is opposite to gravity [import]uid: 160496 topic_id: 30008 reply_id: 120198[/import]

I don’t think you get me. With the library I gave you the link to, you use it by setting the gravity to 0 and then adding the gravity to each thing individually. That means you can set the bird to a dynamic physics shape and just not add gravity (from the module) to it. Then add gravity to everything else and there you go. You have one bird that does not fall under gravity (but is still dynamic) and everything else that does fall under gravity.

quinc [import]uid: 147322 topic_id: 30008 reply_id: 120200[/import]

@quinc,
Apologies for not understanding, Iam with you now.
Sounds promising.
I’ve been attempting to find an app with what I propose but can only find mainly objects and sprite using what I figure is impulse and angular physics to propel them.
I was all for canning the project, then considered the invisible rect collision filters with sensor.
I hope to try what you suggest asap.
Thankyou [import]uid: 127675 topic_id: 30008 reply_id: 120208[/import]

@quinc,

hi, I have tried to implement gg into a very simple project.i.e. a ball only on screen in order to understand your library.
I can not for life of me get physics applied to the object ?
I am just getting REs in the module as force is applied, line 25.
Would you be so kind as to provide some simple example code in a main.lua on calling and implementing the the module on say a ball or rect?
Apologies if this a simple question but I am calling the module as normal but struggling.

thank you Quinc [import]uid: 127675 topic_id: 30008 reply_id: 120241[/import]

I’ll add it to the library. You can just use the earlier link to get to it. [import]uid: 147322 topic_id: 30008 reply_id: 120244[/import]