Skip to content

Instantly share code, notes, and snippets.

@gooderist
Last active February 20, 2018 05:45
Show Gist options
  • Save gooderist/778008db24905a57c50279571cb7a8c5 to your computer and use it in GitHub Desktop.
Save gooderist/778008db24905a57c50279571cb7a8c5 to your computer and use it in GitHub Desktop.
How to start a new win32 cocos2d-x / box2d / LevelHelper2-API project

Steps to setup a new win32 cocos2d-x project with LevelHelper2-API and Box2D support

Things you will need

Preliminary Setup

  • Install Visual Studio
  • Install cocos2d-x and run the setup.py script
  • Use cocos command to create a new game project (ex: cocos new NewGame -l cpp)
  • Copy LevelHelper2-API folder into new game project folder
  • Open VS solution in proj.win32 folder (launches VS2015)

Inside Visual Studio

  • In the main project in your solution (NewGame) right click and go to Properties
    • Under C/C++ -> General -> Additional Include Directories
    • Add ..\LevelHelper2-API;$(EngineRoot);$(EngineRoot)cocos\ui;
    • Under C/C++ -> Preprocessor -> Preprocessor Definitions
    • Add LH_USE_BOX2D=1
    • (Optionally) set CC_ENABLE_CHIPMUNK_INTEGRATION=0
    • Do the same for Release as for Debug
  • Right click main project again and Add->New Filter named LevelHelper2-API
  • From file manager, drag LevelHelper2-API folder into the LevelHelper2-API filter you just made
  • Make the following changes to LevelHelper2-API files
    • LHUtils.cpp surround float fmin() and float fmax() with #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
  • If you are using Chipmunk instead of Box2D you might instead want to do the following
    • LHJointsProtocol.cpp comment out removeJoint()'s _joint->removeFormWorld(); causes bad mem access
    • LHRopeJointNode.cpp add if (cutJointA) above cutJointA->removeFormWorld(); and do same for cutJointB

That should get you to the point where you can #include "LevelHelper2API.h", compile, and run!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment