Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Building Android Games with Cocos2d-x
  • Toc
  • feedback
Building Android Games with Cocos2d-x

Building Android Games with Cocos2d-x

By : Hernandez
4.3 (8)
close
Building Android Games with Cocos2d-x

Building Android Games with Cocos2d-x

4.3 (8)
By: Hernandez

Overview of this book

If you have a basic understanding of the C++ programming language and want to create videogames for the Android platform, then this technology and book is ideal for you.
Table of Contents (10 chapters)
close
9
Index

Understanding actions

We can easily tell our sprites to perform concrete actions, such as jump, move, skew, and so on. It requires a few lines to get our sprites to execute the desired action.

Moving sprites

We can make our sprite move to a specific area of the screen by creating a MoveTo action and then making the sprite execute the action.

In the following code listing, we are making the bomb fall to the bottom of the screen by simply writing the following code lines:

  auto moveTo = MoveTo::create(2, Vec2(sprBomb->getPositionX(), 0 - sprBomb->getContentSize().height/2));
  sprBomb->runAction(moveTo);

We have created a moveTo node that will move the bomb sprite to the current horizontal position, but it will also move it to the bottom of the screen until it is not visible. In order to achieve this, we made it move to the y position of the negative half of the height of the sprite. Since the anchor point is set to the center point of the sprite, moving it to the negative half of its...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete