collision while using sprite sheet in corona - coronasdk

how can i create collision between the objects added to physics body and sprite sheet...
as i dont want to add my sprite sheet in physics...

You can use a blank rect to map the position of your sprite and handle collisons based on that

Related

How to return the SKSpriteNode within given constraints following an event?

Suppose the following:
You have a myriad of SKSpriteNodes in the view.
When the user taps the screen, you want the whatever sprite that is in / near a specific location to do an animation.
Question: How can figure out which SKSpriteNode is at the specific location without looping through all sprites?
For this, I have implemented a SKSpriteNode, box, which is transparent and has a texture which covers the span of the specific location, and is positioned accordingly.
The SKSpriteNode methods contains and intersects seem promising, but require that I pass a point or a sprite respectively.
Question: How can I get a SKSpriteNode to report what sprite, if any, it intersects with? Again, without looping through every sprite. If two sprites intersect with box, then return only that which is most prominently intersecting with box.
Diagram:
This is not my actual use case, but illustrates the point. There are a lot of sprites (more than visualized below) and there is an area of interest that:
if the user touches, and
a sprite is in that area
I want to know what sprite is there.
There is no way to do this without SOMETHING looping through the sprites. That's either:
The physics engine, as Stoneburner suggests
The scene, via update() setting flags on sprites when they're in the
region
Your code that handles the touch, searching for sprites in the region
GameplayKit offers some optimisations on doing this sort of thing: https://developer.apple.com/reference/gameplaykit/gkrtree
Attach a UITapGestureRecognizer to the view
On tap state UIGestureRecognizerStateRecognized get the location of the tap using CGPoint pointInView = [tapper locationInView:mySKScene.view]
Convert from the view's coordinate system to the scene's coordinate system using CGPoint pointInScene = [mySKScene convertPointFromView:pointInView]
Get the node at that point by asking the scene. SKNode *touchedNode = [self nodeAtPoint:pointInScene];
You can use SKPhysicsBodies to detect collisions (overlaps).
Assign physicsbodies to all sknodes, add one dynamically on the region you want to detect sknodes inside, handle the SKPhysicsContactDelegate, remove the body again

iOS: move circle shape view by collision by dragging another?

I have two UIViews shaped like a circle. (see image).
I am trying to figure out how to make the two views move by collision.
So I am moving one with a touch by changing it's position as I move my finger on it. I want to see the other move as I "push" the one I am moving against the other circle shaped view.
What is the correct way to achieve this?
Using SceneKit did the trick. I created the geometries and then applied physic bodies to each. With the proper physics configuration in the scene they now collide.

Movement of Box2d Body in cocos2d-x

I need to move the box2d body according to position received form game center server.
After receiving position I just update the body position using: -
Carbody->SetTransform(b2Vec2(serverposition.x,serverposition.y),0);
But its moving the body inapprotiate manner (for example. Body is showing somewere lese in the screen). At same time my sprite image not moving (attached with body).
What i did to solve the positioning problem is i taken a normal sprite image and just change position in update with that box2d body position.
Eg:-
your carbody movement based on server position. it will move invisibly.
your b2body without userdata(image)
carMainBody->SetTransform(b2Vec2(serverposition,carMainBody->GetPosition().y), 0.0f);
here your normal sprite image. just attch your sprite image like this
car->setPosition(ccp(carMainBody->GetPosition().x*PTM_RATIO,carMainBody->GetPosition().y*PTM_RATIO));
This method worked fine for me.

Move Scene in corona

I am new to corona and my Problem id I have a long scene and in that I have a ball body. When it moves up i want to move the scene up. How to do this in Corona.
This is done using a display group to contain your entire scene (the level, the ball, everything) and then move that display group. Physics in Corona don't work between display groups for this very reason, so that that you can move the scene without affecting physics inside the scene. Refer to the "Egg Breaker" sample project.

Making a Sprite unmovable...[Chipmunk & Cocos2D]

Im using Chipmunk with Cocos2d to make a gravity based puzzle game, however I have reached a part of my project whereby I need a sprite that once drawn does not move and cannot be moved by the other sprites within the environment.
In essence...
Can I create a static (non moving) sprite that is not affected by in game gravity or other objects in the game.
Thanks in advance I've only been doing this project a week....
Yes, this is possible.
1) Create a body with infinite mass and moment.
2) Do not add the body to the space.
3) Create the desired shape.
Use cpSpaceAddStaticShape to add the shape to the space.

Resources