Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Physics? Questions — Gideros Forum

Physics? Questions

rdkemptrdkempt Member
edited April 2012 in General questions
I have two questions I have been stumped with and I am sure they are simple solutions I have not yet been able to find answers for!

1) I have gravity pull all objects down off the screen and new objects show up at the top. All objects get faster the further down the screen they go, as their velocity increases from the gravity. Great. However, I do not want the velocity of a particular object to ever change. I want it to be very slow, and stay at the same speed from top to bottom. As a ghetto fix I have setup a timer and applied a force against it to slow it down for now, this shouldn't be a viable long-term solution?

2) Shape defintion - I have some very large, and strange shaped objects (imagine the letter S or Z). They are images so I am just using the image size for the shape right now, however, if something is inside the empty areas of the letters, collision should not occur. These files use a transparent background, is there a way to detect transparency and if not, what would be the best way to define the areas of this object so that another object can go inside these empty areas but not the actual letters?

Dislikes: Tom2012

+1 -1 (+0 / -1 )Share on Facebook

Comments

  • For 1, I don't have an answer. Looking through the interwebs I didn't find anyone who had a great solution, but there are a lot of solutions out there.

    For 2, there's no way to do this within Gideros itself (i.e., look at alpha areas and build up list of convex polygons). You can use 3rd party tools that will automatically decompose a complex shape into multiple convex polygons. Some of the tools include Box2d Editor (http://code.google.com/p/box2d-editor/) and Physics Editor (http://www.physicseditor.de/). Physics Editor added support for Gideros in version 1.0.9 (see note in: http://www.physicseditor.de/download/) but I've never used it. I made a very amateur attempt a while back to use the Box2d Editor w/ Gideros @ https://github.com/ndoss/gideros_playground/tree/master/box2d_editor_example.

    Likes: avo

    +1 -1 (+1 / -0 )Share on Facebook
  • avoavo Member
    edited April 2012
    For #2 you are probably going to need to create polygon objects using something like http://www.physicseditor.de/features/ which now has export for Gideros in both the Mac and Windows version.

    You could also do it by hand but I imagine that would be very time consuming.

    edit: aha ndoss with a faster and better answer :)

    Likes: ndoss

    +1 -1 (+1 / -0 )Share on Facebook
  • @avo, Ha ... beat you by 1 minute!
  • rdkemptrdkempt Member
    edited April 2012
    Thank you very much guys, I will take a look at some of those 3rd party tools... I was very afraid I was going to spend 200,000 hours manually defining each bump in some of these objects. Lol. I will refine my timer / force, maybe play with setLinearVelocity on my timer too for #1 for now. =\

    EDIT: I suppose I could also put it on a timer and set it's position slightly below it's current position etc... and define the object as static? Would be nice to just have a VelocityIncrease = false type option though. Lol
  • ar2rsawseenar2rsawseen Maintainer
    Are there a lot of objects? You could disable gravity at all, by providing 0 vector, and then apply force to object once, to start it moving, and it should move with constant speed to the force direction.
    Problem is, when there are many objects, they can collide and change force direction.

    You can also try to combine, low gravity with applying force in direction of gravity (not against it).

    Don't forget about linear dampening for bodies. I think it is possible to increase it to work against gravity.

    Last thing that comes to mind, you could tween a static or kinetic body, so it moves the way you need at speed what you need.

    There are plenty of solutions, just need to experiment, to find most suitable for you.
  • Thanks for more suggestions (and more reading material!). I'm an experienced PHP and SQL developer but Lua and Box2d are very new to me so I am unaware of all of my options.

    I only have 2 objects I do not want to have the speed increase on. At any given time, there are about 6-10 objects, 3 walls, and 2 objects I don't want to increase the speed on displayed on the screen.
  • kussakovkussakov Member
    edited May 2012
    Have you tried gravityScale parameter while creating your slow moving bodies?
Sign In or Register to comment.