Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
I am finding Gideros Studio nice and simple except for... — Gideros Forum

I am finding Gideros Studio nice and simple except for...

mykyl66mykyl66 Member
edited November 2011 in User experience
I am finding Gideros Studio nice and simple except for the physics stuff. For example I had the issue with the revolute joints earlier which was answered and now I am am having issues setting an object as a sensor.

The one thing I would ask for is more information on putting together physics based games. I understand that I need to create a fixture which is done but when setting the object as a sensor it always returns nil.

Why cant I just say "thisBody:setSensor(true) and it just work?

Cheers from the thick one.

Mike

Likes: kontinyu, Yan

What would you do for your other half?

http://www.sharksoupstudios.com
+1 -1 (+2 / -0 )Share on Facebook

Comments

  • You setSensor() on the fixture, not the body, if that helps.
  • atilimatilim Maintainer
    Because sensor property belongs to fixtures, not bodies.

    You can set isSensor field as true while creating fixture definition table like:
    myFixtureDef = {shape = shape, isSensor = true, .....}
    myBody:createFixture(myFixtureDef)
    or you can setSensor(true) after creating the fixture
    local myFixture = myBody:createFixture(myFixtureDef)
    myFixture:setSensor(true)
    On the other hand, I agree with you about the physics API. It's not very easy and only the Gideros reference manual have information about it. We're working on it (more documentation and easy physics layer on top of current Box2d API)
  • Right it was my code that was mucking it up. I created a second function for creating sensor objects in one line and now that works.

    Thanks for the fast help.

    Mike
    What would you do for your other half?

    http://www.sharksoupstudios.com
  • I am having some issues, around the sensor thing. and that is, how do I detect a sensor has been triggered?
    I have basically a square, with an opening, and the sensor is in the centre, when I hist the box with my character the onBeginContact is triggered, but the bodyA or B name is the object name, rather than the individual sensor, whats the trick to see if the sensor has been triggered?
    REAL programmers type copy con filename.exe
    ---------------------------------------
  • @Cyberience :
    Well, for that you need to add name to fixture A and fixture B instead.
  • To be more clear, this is my physics object, called window. and when I get the begincontact call the name is window. but what I need to establish is if the sensor labelled home is triggered.
    {code}
    ["window"] = {
    anchorPoint = { 0.498, 0.018}, fixtures = {
    {
    pe_fixture_id = "home", density = 2, friction = 0, restitution = 0, sensor=true,
    filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
    shape = { 75.9999995, 100.00000028 , 69.9999995, 215.00000028 , -70.0000005, 214.00000028 , -78.0000005, 96.00000028 }
    }
    {
    pe_fixture_id = "frame", density = 2, friction = 0, restitution = 0, sensor=false,
    filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
    shape = { -80.0000005, 103.00000028 , -76.0000005, 245.00000028 , -119.0000005, 271.00000028 , -133.0000005, 65.00000028 }
    }
    {
    pe_fixture_id = "frame", density = 2, friction = 0, restitution = 0, sensor=false,
    filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
    shape = { 118.9999995, 269.00000028 , 73.9999995, 243.00000028 , 80.9999995, 97.00000028 , 134.9999995, 70.00000028 }
    }
    {
    pe_fixture_id = "", density = 2, friction = 0, restitution = 0, sensor=false,
    filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
    shape = { -125.0000005, 71.00000028 , 0.999999500000001, 1.00000027999999 , 122.9999995, 72.00000028 }
    }
    }
    } {/code}
    And the called code is as follows:
    {code}
    local fixtureA = e.fixtureA
    local fixtureB = e.fixtureB
    local bodyA = fixtureA:getBody()
    local bodyB = fixtureB:getBody()
    if bodyA.name then
    print("a:"..bodyA.name)
    end
    if bodyB.name then
    print("b:"..bodyB.name)
    end
    {/code}

    Ideas?
    REAL programmers type copy con filename.exe
    ---------------------------------------
Sign In or Register to comment.