How to drag a sprite in cocos2d-x

Hi friends. In this tutorial we will learn how to drag a sprite in cocos2d-x
Step 1
Create a new project and delete everything in init() function of HelloWorldScene.cpp

Step 2
In your HelloWorldScene.h write
#include “cocos2d.h”
using namespace cocos2d;

Step 3
Write the following code in your init function and add any sprite

Now define all the touch functions and other as follows

Now run the project and you will be able to drag the sprite
HAPPY CODING

4,470 total views, 3 views today

Share this OnShare on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Leave a Reply