Moving automatically Physics Platform (the better way?) - coronasdk

I have some platforms ("static Object") where my player jump ("Dynamic Object") onto them to get coins.
I would like know what the better way to make moving my physics platform automatically on the screen ?
Is it the transtition.to() the only way to do that ? Or the Velocity could do it ? Or something else ?
Thanks for your reply, I need really to know that to goahead in my game.

When its the case to move physics objects, transition.to() is not recommended. You can simply create a method, which will work in enterFrame and change the position of the object. If you encounter some problems, you can try to change object types of the platforms to "Kinematic".

Thanks dude,
At last, I'm using the velocity and the "kynematic" physic, that's the best way and the easiest I think.
Because transition.to that's so hard with physics

Related

Does the usePreciseCollisionDetection property work when the physics body does not have a collisionBitMask

I do not want my physics bodies to collide when they come in contact, but I want to use the
physicsBody?.usesPreciseCollisionDetection = true so that it detects contacts between the two bodies more accurately. So if I set
physicsBody?.collisionBitMask = PhysicsCategory.None //Assume that PhysicsCategory is an Enum and .None means that the bit mask is set to 0 or nothing
physicsBody?.usesPreciseCollisionDetection = true
Will the usesPreciseCollisionDetection still be valid? And if not, how to I implement more precise contact testing?
Thanks
you usually need usesPreciseCollisionDetection to make sure that a fast moving object isnt passing through a set of tiles or other physics objects that are pressed together. if youre just using the physics object as a sensor (just to test for collisions) then you probably dont need to use that. I would guess that it works either way since the documentation doesnt say otherwise, but i dont think theres any way to know for sure..
EDIT: It does matter.. if you want to detect fast moving objects set usesPreciseCollisionDetection to true. You need it whether you have a collisionbitmask set or not. Thanks Whirlwind!

create trampoline-like effect in cocos2d

I need implement trampoline-like effect like in this question and apply a force to a body when it collides with trampoline.
But how can I detect this moment?
Or maybe can I just create a body which can't move by gravity or other bodies, but has a trampoline effect?
Do you want to create more force than provided by restitution?
Well you can do this all.....
One way is set restitution as 0.9 or 1(of both the bodies in contact)... the other way is get those bodies by tag and then apply linearImpulse on the body you want trampoline effect....
I hope this helps

CORONA SDK Physics that dont affect every sprite

I want to make some sprites affected by physics gravity, but not all of them in the display screen. For example, the player don't need to be affected and, when collision with another, this one leaves another sprite object that will be affected.
Sorry for my english i'm foreign and try to explain better I can do.
Thanks!!!.
Check this thread out,
Collision Filtering
or check for collision filtering and masking bits.
Are you looking for this?
http://docs.coronalabs.com/api/type/Body/gravityScale.html
Setting gravityScale for a physics body to zero makes it unaffected by gravity.
myObj.gravityScale = 0
Setting it to a negative value makes it "float", for example if you want a balloon going up :)

Making a Drawable layer in cocos2d

I want to make sort of a chalk board for part of my app, and I was wondering how to accomplish this?
I was thinking I could create a sprite and have it's image set to something very small (maybe a small point), and then add a new instance of that sprite everywhere the user touches to simulate a draw event. Something like [self addChild:someSprite]; for each touch location.
But it seems like that would be extremely memory inefficient. There has to be a better way than that, Maybe drawing actual lines? I'm probably overlooking some method.
Thanks for any help.
You need to use CCRenderTexture for chalk board paintings. Check this article & project for a drawing example.
Your variant isn't such "memory inefficient" as you think. No matter how much sprites will you create with the same texture, your texture will be placed to the memory only once. And all the sprites will use pointer to it. Just one thing to prevent many unnessesary calls is to use CCBatchNode. It will draw all it's children with single draw call. Without using it, draw will be called on every children.

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

Resources