Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Cocos2d-x cookbook
Cocos2d-x cookbook

Cocos2d-x cookbook: Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-x

eBook
€20.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Cocos2d-x cookbook

Chapter 2. Creating Sprites

In this chapter we're going to create sprites, animations, and actions. The following topics will be covered in this chapter:

  • Creating sprites
  • Getting the sprite's position and size
  • Manipulating sprites
  • Creating animations
  • Creating actions
  • Controlling actions
  • Calling functions with actions
  • Easing actions
  • Using a texture atlas
  • Using a batch node
  • Using 3D models
  • Detecting collisions
  • Drawing a shape

Introduction

Sprites are a 2D image. We can animate and transform them by changing their properties. Sprites are basically, items and your game is not complete without them. Sprites are not only displayed, but also transformed or moved. In this chapter, you will learn how to create sprites using 3D models in Cocos2d-x, and then, we will go through the advantages of sprites.

Creating sprites

Sprites are the most important things in games. They are images that are displayed on the screen. In this recipe, you will learn how to create a sprite and display it.

Getting ready

You can add the image that you made in the previous chapter into your project, by performing the following steps:

  1. Copy the image into the Resource folder MyGame/Resources/res.
  2. Open your project in Xcode.
  3. Go to Product | Clean from the Xcode menu.

You have to clean and build when you add new images into the resource folder. If you did not clean after adding new images, then Xcode will not recognize them. Finally, after you add the run_01.png to your project, your project will be seen looking like the following screenshot:

Getting ready

How to do it...

We begin with modifying the HelloWorld::init method in the following code:

bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size size = Director::getInstance()->getWinSize();
    auto sprite = Sprite::create("res/run_01...

Getting the sprite's position and size

There is a certain size and position of the sprite. In this recipe, we explain how to view the size and position of the sprite.

How to do it...

To get the sprite position, use the following code:

Vec2 point = sprite->getPosition();
float x = point.x;
float y = point.y;

To get the sprite size, use the following code:

Size size = sprite->getContentSize();
float width = size.width;
float height = size.height;

How it works...

By default, the sprite position is (0,0). You can change the sprite position using the setPosition method and get it using the getPosition method. You can get the sprite size using the getContentSize method. However, you cannot change the sprite size by the setContentSize method. The contentsize is a constant value. If you want to change the sprite size, you have to change the scale of the sprite. You will learn about the scale in the next recipe.

There's more...

Setting anchor points

Anchor point is a point that you set...

Manipulating sprites

A Sprite is a 2D image that can be animated or transformed by changing its properties, including its rotation, position, scale, color, and so on. After creating a sprite you can obtain access to the variety of properties it has, which can be manipulated.

How to do it...

Rotate

You can change the sprite's rotation to positive or negative degrees.

sprite->setRotation(30.0f);

You can get the rotation value using getRotation method.

float rotation = sprite->getRotation();

The positive value rotates it clockwise, and the negative value rotates it counter clockwise. The default value is zero. The preceding code rotates the sprite 30 degrees clockwise, as shown in the following screenshot:

Rotate

Scale

You can change the sprite's scale. The default value is 1.0f, the original size. The following code will scale to half size.

sprite->setScale(0.5f);

You can also change the width and height separately. The following code will scale to half the width only.

sprite->setScaleX...

Creating animations

When the characters in a game start to move, the game will come alive. There are many ways to make animated characters. In this recipe, we will animate a character by using multiple images.

Getting ready

You can create an animation from a series of the following image files:

Getting ready

You need to add the running girl's animation image files to your project and clean your project.

Tip

Please check the recipe Creating sprites, which is the first recipe in this chapter, on how to add images to your project.

How to do it...

You can create an animation using a series of images. The following code creates the running girl's animation.

auto animation = Animation::create();
for (int i=1; i<=8; i++) {  // from run_01.png to run_08.png
    std::string name = StringUtils::format("res/run_%02d.png", i);
    animation->addSpriteFrameWithFile(name.c_str());
}
animation->setDelayPerUnit(0.1f);
animation->setRestoreOriginalFrame(true);
animation->setLoops(10);
auto...

Creating actions

Cocos2d-x has a lot of actions, for example, move, jump, rotate, and so on. We often use these actions in our games. This is similar to an animation, when the characters in a game start their action, the game will come alive. In this recipe you will learn how to use a lot of actions.

How to do it...

Actions are very important effects in a game. Cocos2d-x allows you to use various actions.

Move

To move a sprite by a specified point over two seconds, you can use the following command:

auto move = MoveBy::create(2.0f, Vec2(100, 100));
sprite->runAction(move);

To move a sprite to a specified point over two seconds, you can use the following command:

auto move = MoveTo::create(2.0f, Vec2(100, 100));
sprite->runAction(move);

Scale

To uniformly scale a sprite by 3x over two seconds, use the following command:

auto scale = ScaleBy::create(2.0f, 3.0f);
sprite->runAction(scale);

To scale the X axis by 5x, and Y axis by 3x over two seconds, use the following command:

auto scale = ScaleBy...

Introduction


Sprites are a 2D image. We can animate and transform them by changing their properties. Sprites are basically, items and your game is not complete without them. Sprites are not only displayed, but also transformed or moved. In this chapter, you will learn how to create sprites using 3D models in Cocos2d-x, and then, we will go through the advantages of sprites.

Creating sprites


Sprites are the most important things in games. They are images that are displayed on the screen. In this recipe, you will learn how to create a sprite and display it.

Getting ready

You can add the image that you made in the previous chapter into your project, by performing the following steps:

  1. Copy the image into the Resource folder MyGame/Resources/res.

  2. Open your project in Xcode.

  3. Go to Product | Clean from the Xcode menu.

You have to clean and build when you add new images into the resource folder. If you did not clean after adding new images, then Xcode will not recognize them. Finally, after you add the run_01.png to your project, your project will be seen looking like the following screenshot:

How to do it...

We begin with modifying the HelloWorld::init method in the following code:

bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size size = Director::getInstance()->getWinSize();
    auto sprite = Sprite::create("res/run_01.png"...

Getting the sprite's position and size


There is a certain size and position of the sprite. In this recipe, we explain how to view the size and position of the sprite.

How to do it...

To get the sprite position, use the following code:

Vec2 point = sprite->getPosition();
float x = point.x;
float y = point.y;

To get the sprite size, use the following code:

Size size = sprite->getContentSize();
float width = size.width;
float height = size.height;

How it works...

By default, the sprite position is (0,0). You can change the sprite position using the setPosition method and get it using the getPosition method. You can get the sprite size using the getContentSize method. However, you cannot change the sprite size by the setContentSize method. The contentsize is a constant value. If you want to change the sprite size, you have to change the scale of the sprite. You will learn about the scale in the next recipe.

There's more...

Setting anchor points

Anchor point is a point that you set as a way...

Manipulating sprites


A Sprite is a 2D image that can be animated or transformed by changing its properties, including its rotation, position, scale, color, and so on. After creating a sprite you can obtain access to the variety of properties it has, which can be manipulated.

How to do it...

Rotate

You can change the sprite's rotation to positive or negative degrees.

sprite->setRotation(30.0f);

You can get the rotation value using getRotation method.

float rotation = sprite->getRotation();

The positive value rotates it clockwise, and the negative value rotates it counter clockwise. The default value is zero. The preceding code rotates the sprite 30 degrees clockwise, as shown in the following screenshot:

Scale

You can change the sprite's scale. The default value is 1.0f, the original size. The following code will scale to half size.

sprite->setScale(0.5f);

You can also change the width and height separately. The following code will scale to half the width only.

sprite->setScaleX(0...

Creating animations


When the characters in a game start to move, the game will come alive. There are many ways to make animated characters. In this recipe, we will animate a character by using multiple images.

Getting ready

You can create an animation from a series of the following image files:

You need to add the running girl's animation image files to your project and clean your project.

Tip

Please check the recipe Creating sprites, which is the first recipe in this chapter, on how to add images to your project.

How to do it...

You can create an animation using a series of images. The following code creates the running girl's animation.

auto animation = Animation::create();
for (int i=1; i<=8; i++) {  // from run_01.png to run_08.png
    std::string name = StringUtils::format("res/run_%02d.png", i);
    animation->addSpriteFrameWithFile(name.c_str());
}
animation->setDelayPerUnit(0.1f);
animation->setRestoreOriginalFrame(true);
animation->setLoops(10);
auto action = Animate::create...

Creating actions


Cocos2d-x has a lot of actions, for example, move, jump, rotate, and so on. We often use these actions in our games. This is similar to an animation, when the characters in a game start their action, the game will come alive. In this recipe you will learn how to use a lot of actions.

How to do it...

Actions are very important effects in a game. Cocos2d-x allows you to use various actions.

Move

To move a sprite by a specified point over two seconds, you can use the following command:

auto move = MoveBy::create(2.0f, Vec2(100, 100));
sprite->runAction(move);

To move a sprite to a specified point over two seconds, you can use the following command:

auto move = MoveTo::create(2.0f, Vec2(100, 100));
sprite->runAction(move);

Scale

To uniformly scale a sprite by 3x over two seconds, use the following command:

auto scale = ScaleBy::create(2.0f, 3.0f);
sprite->runAction(scale);

To scale the X axis by 5x, and Y axis by 3x over two seconds, use the following command:

auto scale = ScaleBy...

Controlling actions


In the previous recipe, you learned some of the basic actions. However, you may want to use more complex actions; for example, rotating a character while moving, or moving a character after jumping. In this recipe, you will learn how to control actions.

How to do it...

Sequencing actions

Sequence is a series of actions to be executed sequentially. This can be any number of actions.

auto move = MoveBy::create(2.0f, Vec2(100, 0));
auto rotate = RotateBy::create(2.0f, 360.0f);
auto action = Sequence::create(move, rotate, nullptr);
sprite->runAction(action);

The preceding command will execute the following actions sequentially:

  • Move a sprite 100px to the right over two seconds

  • Rotate a sprite clockwise by 360 degree over two seconds

It takes a total of four seconds to execute these commands.

Spawning actions

Spawn is very similar to Sequence, except that all actions will run at the same time. You can specify any number of actions at the same time.

auto move = MoveBy::create(2.0f...

Calling functions with actions


You may want to call a function by triggering some actions. For example, you are controlling the sequence action, jump, and move, and you want to use a sound for the jumping action. In this case, you can call a function by triggering this jump action. In this recipe, you will learn how to call a function with actions.

How to do it...

Cocos2d-x has the CallFunc object that allows you to create a function and pass it to be run in your Sequence. This allows you to add your own functionality to your Sequence action.

auto move = MoveBy::create(2.0f, Vec2(100, 0));
auto rotate = RotateBy::create(2.0f, 360.0f);
auto func = CallFunc::create([](){
    CCLOG("finished actions");
});
auto action = Sequence::create(move, rotate, func, nullptr);
sprite->runAction(action);

The preceding command will execute the following actions sequentially:

  • Move a sprite 100px to the right over two seconds

  • Rotate a sprite clockwise by 360 degrees over two seconds

  • Execute CCLOG

How it works...

Left arrow icon Right arrow icon

Description

Cocos2d-x is a suite of open source, cross-platform game-development tools used by thousands of developers all over the world. Cocos2d-x is a game framework written in C++, with a thin platform-dependent layer. Completely written in C++, the core engine has the smallest footprint and the fastest speed of any other game engine, and is optimized to be run on all kinds of devices. You will begin with the initial setup and installation of Cocos2d before moving on to the fundamentals needed to create a new project. You will then explore and create the sprites, animations, and actions that you will include in the game. Next you will look at strings and create labels, including a label with True Type Font (TTF) font support. Later, you will learn about layer and scene creation and transition. Then you will create the GUI parts essential for a game, such as buttons and switches. After that, you will breathe life into the game with background music and sound effects using the all new Cocos2d-x audio engine. You will then discover how to manage resource files and implement processes that depend on the operating system. Finally, you will polish your game with physics such as gravity and elevation, learn about tools that will help you make games more robust and stable, and get to know best practices to improve the game you have developed.

Who is this book for?

If you are a game developer and want to learn more about cross-platform game development in Cocos2d-x, then this book is for you. Knowledge of C++, Xcode, Eclipse, and how to use commands in the terminal are prerequisites for this book.

What you will learn

  • Install and set up Cocos2dx for your development environment
  • Build, test, and release game applications for iOS and Android
  • Develop your games for multiple platforms
  • Customize Cocos2dx for your games
  • Use a physical engine in your games
  • Save and load text, JSON, XML, or other formats
  • Explore the brand new features of Cocos2dx
Estimated delivery fee Deliver to France

Premium delivery 7 - 10 business days

€10.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 03, 2015
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783284757
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to France

Premium delivery 7 - 10 business days

€10.95
(Includes tracking information)

Product Details

Publication date : Nov 03, 2015
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783284757
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
Cocos2d-x cookbook
€36.99
Cocos2d-X Game Development Blueprints
€41.99
Cocos2d-x by example (update)
€36.99
Total 115.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Getting Started with Cocos2d-x Chevron down icon Chevron up icon
2. Creating Sprites Chevron down icon Chevron up icon
3. Working with Labels Chevron down icon Chevron up icon
4. Building Scenes and Layers Chevron down icon Chevron up icon
5. Creating GUIs Chevron down icon Chevron up icon
6. Playing Sounds Chevron down icon Chevron up icon
7. Working with Resource Files Chevron down icon Chevron up icon
8. Working with Hardware Chevron down icon Chevron up icon
9. Controlling Physics Chevron down icon Chevron up icon
10. Improving Games with Extra Features Chevron down icon Chevron up icon
11. Taking Advantages Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(5 Ratings)
5 star 60%
4 star 40%
3 star 0%
2 star 0%
1 star 0%
Kenjis Jan 23, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Cocos2d-x ver.3 での開発について基本から学べて、物理エンジン、加速度センサー、sqlite、http通信など実際のゲームに欠かせない実践的な内容についても分かり易く説明されています。より実践的な一例として、スプライトシート、zipファイル、sqliteファイルの暗号化などについても記載されています。英語が得意でなくても、文章構成がシンプルで説明自体も長々しくなく簡潔で読み易かったです。トピックごとに "Getting ready(準備)"、"How to do it ...(どうやってコード書くか)"、"How it works ...(書いたコードで何が起きるのか) "、"There's more...(さらに詳しく)" といった具合に順序立てており、コード暗記というよりは一般的なゲーム開発の手法も学べるように構成されていると思います。
Amazon Verified review Amazon
Hugo Dec 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is simply awesome, for me is the best source to learn Cocos2d-x development in general and to make a top class game.Starting from the most basic concepts of the game engine, teaching how to use the engine features and how to go more deeply creating your own features based on your needs, using the base that Cocos2d-x have.This book is structured, you have good basis to make all kind of games, you will have one “how-to-do” to almost everything you may need to make your games, I liked because he teaches why he does and how, this way you don't have just a recipe, you have the basis to do much more.He shows how to use advanced techniques to make your games run in more professional style, using hardware communication on Android and iOS, this is very important and you don't find much information about, and he teaches from the basics, and you will feel comfortable to do what you need to do, using the specific platform capabilities.This book covers Physics, SQLite, Tiled Maps, Networking and much more, all the things you may need to make AAA cross-platform games.The author focus on iOS and Android, but you can use for all Cocos2d-x supported platforms, only have to know that if you want to develop to iOS, an Apple machine and an iPhone will be needed, but, all the examples for Android can be executed in all OS's, I use Linux and sometimes Windows, for the specific tools to facilitate your development, all that are mentioned have support for windows, and you may find alternatives, I have my own favorites.I recommend this book for everyone who want to make games, this is the best way to speed your project in a structured, organized and complete way.
Amazon Verified review Amazon
Sergio Martinez-Losa del Rincon Jan 04, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
There is something special in this book, indeed this book covers more than game development with cocos2d-x, it takes advantage of other topics like networking, HTTP request usage and SQLite integration to expand a simple development and turn you game into a great development.Besides this topics, there is a great chapter about physics with simple examples, this is one of the most difficult topic and this chapter makes it easy.The book cover many over themes like font management, UI designing, game UX and sprite sheet design. This book gives a lot of useful information to make a game from scratch to professional and the examples lets you develop a full game step by step.Cocos2d-x is available for several platforms and this books even tells hoe to configure all your tools and resources to build a game for iOS and Android.
Amazon Verified review Amazon
Perry Nally Jan 27, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Pretty great resource if you don't know much about Cocos2d-x. But if you already have knowledge in Cocos2d-x, like how to load sprites, physics, audio, and 3D models then only a part of this book may be useful. There is not much in the way of 3D, other than how to load a 3D model, which seems to have a spelling error in the first section it is described (using "3D modal" instead of "3D model"). Grammatically it needs a bit of work, but I understood everything that was being said.You can definitely use this as a reference or a getting started set of snippets, but all recipes would need to be modified to be implemented in a use-able game/app. That being said, you'll find the networking part very helpful. There does not seem to be enough clarity on the web on how to frame web service calls and process the data. This book helps with that. This is a critical part of securing external logins and other security items. It is a great book and I recommend it, but I cannot say its the most explanatory book on the subject, though it does cover all the relevant topics.Don't get me wrong, this book will help you go in the right direction and implement certain important standards, but you'll need to do your own leg work to figure out how to put all the pieces together.
Amazon Verified review Amazon
aseem gupta Jan 17, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Cocos2d-x current version: v3.9 - has more 3D APIs than 3.4 and also has refactored few 2D APIs. This book uses version 3.4 which is no less than perfect for creating 2D games and you can also use new SDK APIs with it without any trouble as at that time only cocos2d-x SDK APIs were introduced.---------TL;DR---------I expected real game usages would have been demonstrated which can be used directly or with some modifications or atleast would have given picture of where all it can be used. I guess, this is what cookbook stands for and not simply showing working of APIs.But I liked few chapters of this book for different reasons.----------CONS:----------1) Drawing shapes has been shown but real examples of it are not shown. I personally, think that merely showing working API is not a big deal.2) Progress Loader bar is show but timer is used to make progress and not actual resource loading where tough works goes in to implement to find out how many resources are loaded in the memory.3) Page view is shown which is good but this is normal API usage. Could have been better if had shown how page view is implemented to create cool menus like in Angry birds and some other games where on the screen, apart from the current page, some part of left and right page are also shown so that player knows that there is still something to be swiped left/right.---------PROS:---------1) Book is well organised. 'How it works’ part after every topic is good to have.2) Animations using plist is shown which is pretty convenient way if lots of animations are there in a game.3) ScrollView and Page View API usage is shown which you will miss in other places and which I remember I spent good time in implementing by myself. But it's merely API usage and you would have to think on how you can use this to adapt to your needs.4) VideoPlayer api is shown if someone wants to use movie player in his game. On different note, you can also show youtube videos from new SDK APIs.5) Physics chapter is explained nicely. But it uses inbuilt physics engine which is actually built upon chipmunk-not box2d but it’s as good as box2d for many games. I liked changing the gravity using accelerometer - I never thought I could it this way.6) People who are not aware of the tools to pack and use resources of your game in a professional way then you might like chapter 10 ‘’Improving Games with Extra features’.------------------------USPs of this book------------------------1) Chpt7: 'Working with Resource Files' is really good, particularly usage of sqlite for saving game data.2) Chpt11:'Taking Advantages’.a) Encrypting sqlite files for securing game data which is essential if you don't want players to change coins, etc they've earned in the game.b) Sprite sheet encryption is shown but very few games use it as it might need heavy processing before loading the game on mobiles. Anyways, example shows texture packer way for encrypting sprite sheets which is a paid feature.c) Observer pattern is shown which is actually the same as push notification section of the book Cocos2d-x beginner guide by example but with different example.(Just for a note, example in latter book is better example as it directly matches ready to use need. But it might not be the compulsory thing that you might want to add observer pattern, if you're a beginner, in your game because it’s a way how you design code and not something you can't avoid. Also, note, Push Notifications which I just talked about in 2nd book is not same as push notifications that we receive in our smartphones.)d) Http networking is shown which is almost same as cocos2d-x official programmer’s guide example. But this book gives a bit more explanation with a working example which might arouse curiosity in some readers. So, you might like it.e) Using native code(Objective C/Java usage with C++) which can be required by few games where developer wants some kind of processing based on which platform it is. Usage is shown but CCLOG is used which I don’t like in books as I don't find it as a good way to demonstrate a practical example.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela