24. Cocos2dx 3.0 game development: Search for three grid actions: cocos2dx3.0 and cocos2dx3.0

Source: Internet
Author: User

24. Cocos2dx 3.0 game development: Search for three grid actions: cocos2dx3.0 and cocos2dx3.0

Heavy developer labor results, reproduced when please be sure to indicate the source: http://blog.csdn.net/haomengzhu/article/details/37596763


Grid actions are similar to action effects to achieve flip, shock, jitter, water ripple, and other effects.
Grid base class: GridBase * Grid obtains or sets the Grid effect status of the node. The grid is applied to the drawing plane to implement water prints and other 3D effects;
Base Class Definition: cocos2d/2d/CCGrid. h;
Based on this base class, there are two sub-classes: Grid3DTiledGrid3D. The two sub-classes share the same thing: each sub-block of the grid can be separated.
Integration link code:
class CC_DLL GridBase : public Refclass CC_DLL Grid3D : public GridBaseclass CC_DLL TiledGrid3D : public GridBase

Grids are generally not directly applied. You only need to understand Grid3D and TiledGrid3D. You can understand grid-based actions. nodes running grid actions are like multiple rectangles of the same size, through these rectangular actions to form the overall grid action, the 16x12 mesh runs very fast, but the effect is not very good; the 32x24 mesh looks good, however, it won't be too fast to run with time.
Before using grid actions, you need to cancel OpenGL deep Detection: Call
  Director::getInstance()->setDepthTest(true);

Grid actions are used in the same way as normal actions. runAction can be used to run actions,
The specific actions are shown in the following table:

Running Effect of some grid actions:






When you use a grid action, you need to clear the grid after the grid action ends:
void TextLayer::checkAnim(float dt){    //auto s2 = getChildByTag(kTagBackground);    if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != NULL)        _gridNodeTarget->setGrid(nullptr);;}

First, find the target node and check whether there are any other actions on the target node. If the grid is not empty, call the setGrid function and pass in the null parameter (nullptr) to clear the grid; when schedule is used to continuously detect and call this function, the node mesh without action can be cleared.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.