Corona sdk physics object anchor points - lua

Can you tell me how to do this, and if not help me solve this problem? Is it possible to set the new anchor points outside out of the object? I am trying to get an object to rotate around another object. They are physics objects, so I cannot do a transparency trick. Any ideas? Thanks!

You could put the two objects in a display group and set the group's anchor point to be at the center of your main object. The code at http://coronalabs.com/blog/2013/10/15/tutorial-anchor-points-in-graphics-2-0/ should be sufficient. See if that will do the trick for you. Note though that you will have to apply a negative rotation to the main object because you don't want it turning too. If several objects are "in orbit" around main object at different speeds then this trick won't work.

Related

Changing center of mass on body Corona SDK

My question is pretty simple yet I cannot find an answer anywhere in documentation or on stack.
I am working on a game in Corona SDK and I have created a physics body that will be thrown across the screen. The physics body is an image. The object is meant to be a projectile and I would like to use the natural physics inherent to Corona to govern how the object reacts to being thrown across the screen. In order to do this it would be ideal for the object's center of mass to be at the nose/point of the object, somewhat like a badminton shuttle.
The question is: is there a way to set a custom center of mass of a physics body in Corona?
I have figured out how to do this, so I am posting my solution here so that others may find it.
Corona does not have a method or property that can be used to change the center of mass for a particular object.
The best way to change the center of mass of an object is to create another object with a heavier density than the original, position Object B at the x,y of the desired position for the center of mass, then make object B's density greater than Object A. Then using a weld joint, join the two objects and thereafter apply any linear forces to the center of mass of Object B. Object B will then drag Object A along as it is rigidly attached via the weld joint.

How to assign two models to one marker in ARToolKit

I want to make two models appear over one marker in ARToolkit. The key is they much come from two separate WRL files. Is this possible?
I know this is an old question, but maybe it is useful for someone else.
The answer is yes, you can.
The way you do it is to have an empty object that is the parent of the other 2 objects and make that object trackable.
The other 2 objects can define an offset in any direction based on the position of the parent, so they will behave as a scene of sorts, keeping their relative positions.

What does body.GetPosition,body.GetWorldCenter stand for in Box2D?

Recently I have a new project that uses Box2D as physics engine. And I am having some trouble with the body's position.
I want to draw images on the sprite, so I just use body.GetPosition as image's position. But I found that body.GetPosition returns the same value as body.GetWorldCenter, and I just wondering that I did something wrong.
I use box2d flash 2.1a in my project. And I currently subtract this position with half-width and half-height to walk around. Also, can you tell me if there is some way to solve my problem or draw the image in the correct positon in Box2D.
Thank you.
update
so sorry to post before read manual.
after RTM I got that body has two points,first is origin point and the second is center of mass ,so a regular shape's world center is always the same as it's origin point. sorry to post is.
Have you set the image in the userdata for the body? Your getting the body's position but you need to have a function that runs each world tick that can set the images position to the new location. Box2d is just numbers defining a simulation. Those numbers are constantly updating so the image needs to have position set each time there is a game tick. Hope this helps

how to slow down the movement of physics objects in Corona SDKs

I want to slow down the speeds of objects moving with phyics...I want them to move in the same way but to slow down there speed.I hope u understand my problem.thanks
There are multiple ways to do so, depending on what you want to achieve. The simplest way is to set a linear damping value in the body in question. See the documentation here.
Another way, also quite simple, is to apply a force at every frame in the contrary direction as the object moves. You can alter the force applied by the speed the object moves in the direction. See the applyForce method here.
you change the value of gravity .That is use physics.setGravity(0,value).Adjust the speed as you want
Use physics gravity to slow down ur objectphysics.setGravity(-2,10)
Read this website:http://developer.anscamobile.com/reference/index/physicssetgravity

animation in corona

how can i perform animation on my moving object....
and how can i control collisions when some of objects are allowed to collide and some not...i,m beginner to corona and coding as well ...i look all the examples i know there r answers of my questions but i cant understand that properly...so any one help me??
In Corona when you create a Physics body you can specify the body type: static, kinematic, and dynamic.
Static bodies don't move, and don't interact with each other; examples of static objects would include the ground, or the walls of a pinball machine.
Dynamic bodies are affected by gravity and collisions with the other body types.
Kinematic objects are in-between Dynamic and Static bodies but doesn't response to gravity
For more information check these links: http://developer.anscamobile.com/content/game-edition-physics-bodies and http://developer.anscamobile.com/reference/index/physicsaddbody
By "animation" I'm going to assume you mean that the graphic changes. In that case you should use a Spritesheet:
http://developer.anscamobile.com/reference/sprite-sheets
As for collisions, there again I'll make an assumption because your question is a little vague. I interpret your question as wondering how to setup collisions where some objects don't collide with each other, and for that you want to set category and mask bits:
http://developer.anscamobile.com/content/game-edition-collision-detection#Collision_categories_masking_and_groups
It is very easy to make a animation by using corona sdk.If using sprite sheet animation u have use this link http://docs.coronalabs.com/api/library/display/newSprite.html.

Resources