![]() Since the userData deals with "opaque pointers" (Box2d does not know what those are nor what they're for, only you do), and the example uses raw pointers, Box2d will not clean the memory associated to those once the Box2d objects are destroyed, you need to take care of cleaning those.Ī way to do it is to wrap those into smart pointers. The user data is an object that you control and you need hold alive for the whole life of the box2d object. ![]() This part of the official documentation illustrates how this should be done now, however it lacks an important information, IMHO. So it may explain why you see tutorials around that "do no work" with a more recent version of Box2d. They went from storing void pointers to storing an actual object. It seems that box2d recently changed the way they manage userData. When I did something like this, the program is crashing: struct B2_API b2FixtureUserData Next to the structure definition, it is written "You can define this to inject whatever data you want in b2Fixture". ![]() Previously, it was possible, as I understood, to create a body and write: tUserData = smth īut this is not possible because the method returns a structure: b2BodyUserData& b2Body::GetUserData() Void* fixtureUserData = contact->GetFixtureA()->GetUserData() įixturesUnderfoot.erase(contact->GetFixtureB()) //A is foot so B is groundįixturesUnderfoot.erase(contact->GetFixtureA()) //B is foot so A is ground Std::string fixtureUserData = contact->GetFixtureA()->getmy() įixturesUnderfoot.insert(contact->GetFixtureB()) //A is foot so B is groundįixtureUserData = contact->GetFixtureB()->GetUserData() įixturesUnderfoot.insert(contact->GetFixtureA()) //B is foot so A is ground This is what I want to do: class M圜ontactListener : public b2ContactListener But I don't understand how to do this correctly, because just adding a line to the structure of the program crashes. I found out that it is possible to edit the b2FixtureDef structure to add my new data there. After digging through the Box2d files for three days, I realized that I could not cope alone. Now there is no such function and userData should be set in a different way. But with the source of Box2d I have, I don't see the SetUserData functions in the code as I see them in the guides.Īfter understanding it, I realized that these manuals were outdated, and You will learn how to quickly create game prototypes in Gideros, how to test and set up projects to automatically target devices with different resolutions, and how to polish your prototype with animations, sounds, tweens, and even physics to create your very first cross-platform game.īy the end of this book, you will have learned everything you need to create visually stunning physics and exciting cross-platform games using Gideros.Many guides used userData. This book teaches you everything you need to know about Gideros, from installing Gideros on your operating system to creating and efficiently managing your Gideros projects and creating your very first game, all with the help of well explained examples. Gideros Mobile Game Development shows you how to develop an original and exciting game in Gideros, helping you create your very first project and guiding you through the configuration of settings and assets to help you target devices with different resolutions. Gideros also comes with a built-in box2D physics engine and extended memory management features to make mobile game development a breeze. Gideros is a Lua-based framework that facilitates effortless native iOS and Android application development along with hardware acceleration. Have you ever had an interesting idea for a mobile game? Have you ever wanted to jump on the mobile app bandwagon? Developing a mobile game has never been so fun and easy, and with the vast amount of smartphone users, it may also become a profitable thing to do. Full of code examples and descriptions to help you master the basics of mobile game development.Build your very first game following practical and easy to understand instructions.Develop engaging iOS and Android mobile games quickly and efficiently.All that’s required is a little familiarity with Lua. This book shows you how with a real-life project you undertake yourself. ![]() ![]() With Gideros you can develop games for both iOS and Android faster and more simply. ![]()
0 Comments
Leave a Reply. |