Top AppStore Game < don't step on the white block > source analysis and download (i)

Source: Internet
Author: User
Tags addchild

AppStore and Android Market conditions




Somehow the red game

Really inexplicable, the author under this game two times. The first time in the Pea pod list to see this game, the name is strange, download down to try, did not think there is anything new, still thinking this is not brush the list brush up. Decisively unloaded. Browse the App Store on weekends. Suddenly see the top of the leaderboard is dont Tap the white tile (later renamed Panio tiles), translation is not to step on the block. I was shocked. Too inexplicable, this thing is really fire, not brush the list brush out! Gamers are really elusive, and red a game;


Recently exploded red game

From Flappy Bird to 2048 to Dont Tap the white Tile, are all fast track approach games that are made by independent developers, and it seems that individual developers still have the opportunity to get a slice of the game Red Sea. At the same time the author's blog series also experienced these three games.

Flappy Bird Game Source Secrets and download maybe

2048 game source Decryption and download

Don ' t Tap the white tile game source decryption and download



The author of the follow-up

The author is also drifting. What game fire, on open source what game code. Of course it's not a bad thing! is beneficial to all who are in their own. Many children's shoes support you. This Series A total of three articles, the code is not all finished, this article finished the game Classic mode.



Game Source Download

The demo needs to be configured Cocoseditor, and other tools are not supported at this stage. The demo is a cross-platform, portable Execution ANDROID,IOS,HTML5 Web page, etc., and the code is based on the JavaScript language. Cocos2d-x game engine, Cocoseditor Hand Tour development tool finished.

GitHub Download: Https://github.com/makeapp/cocoseditor-piano (recently network reorganization Network disk do not give a holiday set on GitHub go to QQ Group file download)



Under different platforms:


Windows platform



HTML5 platform




Android Platform


watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdg91y2hzbm93/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">


Code Analysis: (Just pick the core master code analysis, many other details to study the source code yourself)


1 Create a music array do, RE, MI, Fa,sol, LA, duo

City_of_sky = [    4, 3, 4, 1, 3, 3, 1, 1, 1, 7, 4, 4, 7, 7, 6, 7, 1, 7, 1, 3, 7, 3, 6, 5, 6, 1, 5, 3, 3    ];


2 Initialize the table, originally created the table of the length of the chart array, but in order to optimize. Create the 4*5 table first, and then continue to add new tables;

Tables    this.tables = new Array (this.pianolengthindex);    for (var j = 0; J < This.pianolength; J + +) {        var sprites = new Array (4);        var random = Getrandom (4);        for (var i = 0; i < 4; i++) {            Sprites[i] = This.newblock (i, J, random);        }        THIS.TABLES[J] = sprites;    }


3 Create a single table element to determine a black element in a line based on ColorType

MainLayer.prototype.newBlock = function (i, J, ColorType) {    //simple block    var block = cc. Sprite.create ("Res/whiteblock.png");    Block.setposition (CC.P (THIS.BLOCKWIDTH/2 + this.blockwidth * I, THIS.BLOCKHEIGHT/2 + this.blockheight * j));    Block.setscalex (This.scalex);    Block.setscaley (This.scaley);    Block.setzorder (+);    Block.setanchorpoint (CC.P (0.5, 0.5));    var color = "White";    if (j = = 0) {        block.setcolor (cc.c3b (0, 255, 0));    } else {        if (i = = ColorType) {Block.setcolor (cc.c3b (            3 0, ());            color = "BLACK";        }    }    Block.blockdata = {col:i, row:j, color:color};    This.blockNode.addChild (block);    return block;};


4 Touch the table. The assumption is black. Assume that the previous line of the current line has the ability to continue;

#假设没到顶, create a new line of moveaddnewsprites, assuming the top. Creates the score end node Createtopovernode.

#假设整个表格移动到顶if (Block.blockData.row = = (this.pianolengthindex-1)). Game End this.gamestatus = over;

#假设没到顶, move the entire table down one line This.blockNode.runAction (cc). Moveto.create (0.2, CC.P (0, (This.blockNode.getPositionY ()-this.blockheight * heightnum)));

#单个元素执行一个缩放动画, move the number of steps +1. This.movenum + = 1;

Touch Black if (Block.blockData.color = = "Black") {if (Block.blockdat A.row = = (This.movenum + 1)) {//create new Sprite if (this                                . pianolength < This.pianolengthindex) {//not reach top this.moveaddnewsprites (); } if (this.pianolength = = This.pianolengthindex) {//when re                                Ach top This.createtopovernode (); }//move down CC.                                Audioengine.getinstance (). Playeffect (Piano_simple[this.pianolistindex[j-1]], false);                                Block.setcolor (cc.c3b (100, 100, 100));                                var heightnum = 1; if (Block.blockData.row = = (this.pianolengthindex-1)) {//when Last row, game success end, MOve-Height heightnum = 2;                                    Cc.log ("End");                                    This.gamestatus = over; Cc.                                Audioengine.getinstance (). Playeffect (Sounds.win, false); } this.blockNode.runAction (CC.                                Moveto.create (0.2, CC.P (0, (This.blockNode.getPositionY ()-this.blockheight * heightnum)));                                This.movenum + = 1; Block.runaction (CC. Sequence.create (CC. Scaleto.create (0, This.scalex * 4/5, This.scaley), CC.                            Scaleto.create (0.2, This.scalex, This.scaley)); }                        }


5 Touch the table. The assumption is white, the game is over.

#创建分数结束节点this. Createtopovernode ();

#改变分数节点的颜色背景, the result fails.

                           This.createtopovernode ();   Create score node and move                             this.gamestatus = over;                            Cc. Audioengine.getinstance (). Playeffect (Sounds.error, false);                            Block.setcolor (cc.c3b (255, 0, 0));                            Block.runaction (CC. Sequence.create (                                cc. Scaleto.create (0, This.scalex * 4/5, This.scaley * 4/5),                                cc. Scaleto.create (0.2, This.scalex, This.scaley))                            ;                            This.scoreNode.bgColor.setColor (cc.c3b (255, 0, 0));                            This.scoreNode.result.setString ("failed");                            This.scoreNode.runAction (CC. Moveto.create (0.2, CC.P (0, This.blockheight * this.movenum)));



6 Create a new line to join
MainLayer.prototype.moveAddNewSprites = function () {    cc.log ("moveaddnewsprites");    var sprites = new Array (4);    var random = Getrandom (4);    for (var k = 0; k < 4; k++) {        Sprites[k] = This.newblock (k, this.pianolength, Random);    }    This.tables[this.pianolength] = sprites;    This.pianolength + = 1;};


7 Fractional End node creation function

MainLayer.prototype.createTopOverNode = function () {//top score node This.scorenode = cc.    Node.create ();    This.scoreNode.setPosition (CC.P (0, This.blockheight * this.pianolength));    This.scoreNode.setAnchorPoint (CC.P (0, 0));    This.scoreNode.setZOrder (130);    This.blockNode.addChild (This.scorenode); Color BG var bgColor = cc.    Sprite.create ("Res/whiteblock.png");    Bgcolor.setposition (CC.P (0, 0));    Bgcolor.setscalex (720/300);    Bgcolor.setscaley (1280/500);    Bgcolor.setanchorpoint (CC.P (0, 0));    Bgcolor.setcolor (cc.c3b (0, 255, 0));    This.scoreNode.addChild (BgColor);    This.scoreNode.bgColor = BgColor;    mode var wordsmode = ["Classic", "Arcade", "Zen"]; var Modelabel = cc.    Labelttf.create (Wordsmode[game_mode] + "mode", "Arial", 70);    This.scoreNode.addChild (Modelabel);    Modelabel.setposition (CC.P (350, 1000));    Modelabel.setcolor (cc.c3b (0, 0, 0));    Modelabel.setanchorpoint (CC.P (0.5, 0.5)); result var ResultLabel = cc. Labelttf.create ("Succeeded", "AriaL ", 110);    This.scoreNode.addChild (ResultLabel);    Resultlabel.setposition (CC.P (360, 750));    Resultlabel.setanchorpoint (CC.P (0.5, 0.5));    Resultlabel.setcolor (CC.C3B (139, 58, 58));    This.scoreNode.result = ResultLabel; back var BackLabel = cc.    Labelttf.create ("Return", "Arial", 50);    This.scoreNode.addChild (BackLabel);    Backlabel.setposition (CC.P (200, 400));    Backlabel.setanchorpoint (CC.P (0.5, 0.5));    Backlabel.setcolor (cc.c3b (0, 0, 0));    This.scoreNode.back = BackLabel; return var Returnlabel = cc.    Labelttf.create ("Redo", "Arial", 50);    This.scoreNode.addChild (Returnlabel);    Returnlabel.setposition (CC.P (500, 400));    Returnlabel.setanchorpoint (CC.P (0.5, 0.5));    Returnlabel.setcolor (cc.c3b (0, 0, 0)); This.scoreNode.return = Returnlabel;};

This is the core code of Classic mode. This article is here;




Cocos2d-x cross-platform game engine
Cocos2d-x is a world-renowned game engine. The engine has a large number of developers around the world, covering a wide range of well-known game developers at home and abroad. Now the Cocos2d-x engine has been implemented across iOS, Android, Bada, MeeGo, BlackBerry, Marmalade, Windows, Linux and other platforms. Write it once and execute it everywhere. Divided into two version numbers cocos2d-c++ and COCOS2D-JS This article uses the latter; Cocos2d-x official website: http://cocos2d-x.org/cocos2d-x Information Download http://cocos2d-x.org/download


Cocoseditor Development tools:

Cocoseditor, which is the development of cross-platform mobile game tools, executes the JavaScript scripting language on the WINDOW/MAC system. Based on the Cocos2d-x cross-platform game engine, collection code editing. Scene design, animation production, font design. There are particles, physical systems. Maps and so on. and debugging convenient, and real-time simulation;

Cocoseditor Download, Introduction and tutorials: http://blog.csdn.net/touchsnow/article/details/19070665;

Cocoseditor Official blog: http://blog.makeapp.co/;



Author's language:

Want to know a lot of other please go to the official blog, the latest blog and code in the official blog debut, please continue to pay attention to, there are many other Cocoseditor game source code is about to release;

Contact Author: [Email protected] (e-mail) QQ Group: 232361142



Top AppStore Game &lt; don't step on the white block &gt; source analysis and download (i)

Related Article

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.