Some newbie questions about the physics implementation

Well, no doubt that things look better and faster now, but i have some questions that i am getting difficult to solve 

  1. at the examples the player is translated on the level with the appliying of forces.What should the best way to control the speed so it has a maxspeed and can ´t go forward?

2 before i used this to move the enemies

 [lua]

mte.moveSpriteTo({sprite = mouse[i], levelPosX=  mRo(mouse[i].levelpos.x+mouse[i].allowedMovement),levelPosY = mRo(mouse[i].levelpos.y),time=4000, easing = “inOutQuad”})

[/lua]

so the movement has an easing and limits.It is possible to get the same movement with easing and limits as now we use forces in place of mte.moveSpriteTo?. Same for moving platforms

  1. an idea how to implement passthrough platforms now?in the older example i use a property called passthrought at the tile so if detects from the bottom then stops

[lua]

if detect.bottom1 and detect.bottom1.passthrought 

    or detect.bottom2 and detect.bottom2.passthrought then

        local loc1X, loc1Y = mte.convert(“levelPosToLoc”, sensors.bottom1[1]), mte.convert(“levelPosToLoc”, nil, sensors.bottom1[2])

        local pos1X, pos1Y = mte.convert(“locToLevelPos”, loc1X) - mte.worldScaleX * 0.5, mte.convert(“locToLevelPos”, nil, loc1Y) - mte.worldScaleY * 0.5

        if velY > 0 then

            tempVelY = velY + (pos1Y - sensors.bottom1[2])

            velY = 0

        end

        isJumping=false

    end

[/lua]

  1. anybody knows a good tutorial on categoriBits and maskBits ?for example if i add an enemy with a category and mask how should i detect the collision between the player and the enemy so i know for example that has been over the enemy = kill the enemy, or a side collision  = kill the player?

  2. i have seen that to detect angled floors some tiles have these properties.

b = 0

m = 1

orientation = down

shape = [-16,-16,16,-16,16,16]

can anybody explain this a bit, specially the shape part?

i know that are many questions hope you can help me, thank to all ans excuse my english

txarly

  1. Damping values: http://docs.coronalabs.com/daily/api/type/Body/linearDamping.html

  2. Do not use transitions or x,y values to move physics objects. You will have strange bugs. You are fighting Box2D if you do that.

  3. Collision event.contact will be useful: http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

4. https://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

  1. Sorry, not sure what you mean here.

thanks horacebury

i wiil take a look at 1 and 3, 

2.- so if a can´t use " mte.moveSpriteTo" may i have to code all the movement of the enemies manually including easing?

4 .- i saw that post before but is no t possible to download the chart

  1. i mean on Tiled, at the platformer - angled example,if you right click some tiles.There are some angled floors(tiles) so the player move over so the body of the tile is not square, it has some properties to make it for example a diagonal tile, the properties i posted before.
  1. If you really want to ‘ease’ a physics object, you should attach a touch joint and move the joint. Play around with the properties of the joint to get the right effect. Just remember that when you are working with physics objects they are not just display objects, but also exist in the physics engine (Box2D) and are subject to very realistic force (gravity, friction, inertia, etc.)

  2. Just use the chart as an aid memoir. You need to make your own chart for your own objects. An easy route is to use the ‘groupIndex’ value: http://developer.coronalabs.com/content/game-edition-collision-detection#Collision_categories_masking_and_groups

  3. I’ve not used Tiled, I’m afraid. Maybe you should work up a simple example that you can post and start a new thread. Workable code demonstrating your specific problem in a few lines can help you think about the problem better and communicate it to others.

The properties b, m, and orientation are there to maintain backward compatibility with the non-physics version of the sample. You can safely delete them if they aren’t needed. The shape is a physics body property defining the shape of the body as a series of coordinates in relation to it’s center. The tiles in the sample are 32 pixels across, so the left edge of the tile is at  x = -16, the top is y = -16, the right is x = 16, and the bottom is y = 16. You pair these or other x,y values together in an array. [-16,-16,16,-16,16,16] means that the coordinates forming the shape are (-16, -16), (16, -16), and (16, 16). There are three coordinates, so this shape is triangular; it is one of the 45-degree slope tiles. Alternatively you can use radius in place of shape for objects which are round, like the green ball tiles. 

  1. Damping values: http://docs.coronalabs.com/daily/api/type/Body/linearDamping.html

  2. Do not use transitions or x,y values to move physics objects. You will have strange bugs. You are fighting Box2D if you do that.

  3. Collision event.contact will be useful: http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

4. https://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

  1. Sorry, not sure what you mean here.

thanks horacebury

i wiil take a look at 1 and 3, 

2.- so if a can´t use " mte.moveSpriteTo" may i have to code all the movement of the enemies manually including easing?

4 .- i saw that post before but is no t possible to download the chart

  1. i mean on Tiled, at the platformer - angled example,if you right click some tiles.There are some angled floors(tiles) so the player move over so the body of the tile is not square, it has some properties to make it for example a diagonal tile, the properties i posted before.
  1. If you really want to ‘ease’ a physics object, you should attach a touch joint and move the joint. Play around with the properties of the joint to get the right effect. Just remember that when you are working with physics objects they are not just display objects, but also exist in the physics engine (Box2D) and are subject to very realistic force (gravity, friction, inertia, etc.)

  2. Just use the chart as an aid memoir. You need to make your own chart for your own objects. An easy route is to use the ‘groupIndex’ value: http://developer.coronalabs.com/content/game-edition-collision-detection#Collision_categories_masking_and_groups

  3. I’ve not used Tiled, I’m afraid. Maybe you should work up a simple example that you can post and start a new thread. Workable code demonstrating your specific problem in a few lines can help you think about the problem better and communicate it to others.

The properties b, m, and orientation are there to maintain backward compatibility with the non-physics version of the sample. You can safely delete them if they aren’t needed. The shape is a physics body property defining the shape of the body as a series of coordinates in relation to it’s center. The tiles in the sample are 32 pixels across, so the left edge of the tile is at  x = -16, the top is y = -16, the right is x = 16, and the bottom is y = 16. You pair these or other x,y values together in an array. [-16,-16,16,-16,16,16] means that the coordinates forming the shape are (-16, -16), (16, -16), and (16, 16). There are three coordinates, so this shape is triangular; it is one of the 45-degree slope tiles. Alternatively you can use radius in place of shape for objects which are round, like the green ball tiles.