Finding images attached to a specific body

General discussion about the R.U.B.E editor
Post Reply
vkreal
Posts: 66
Joined: Sun Jan 13, 2013 7:29 pm

Finding images attached to a specific body

Post by vkreal »

In b2dJson any way to do get image attached to b2Body? something like json.getImageByB2Body(b2Body* body)
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: rube b2dJson

Post by iforce2d »

You could loop over all images to find those with a matching body:

Code: Select all

    std::vector<b2dJsonImage*> allImages;
    json.getAllImages( allImages );

    for (int i = 0; i < allImages.size(); i++) {
        if ( allImages[i]->m_body == theBody )
            // do something with allImages[i]
    }
Post Reply