This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <UIKit/UIKit.h> | |
| #import <Box2D/Box2D.h> | |
| @interface ViewController : UIViewController <UIAccelerometerDelegate> { | |
| b2World* world; | |
| NSTimer *tickTimer; | |
| b2Vec2 gravity; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code by Francois Guibert | |
| // Contact: www.frozax.com - http://twitter.com/frozax - www.facebook.com/frozax | |
| #include "CCShake.h" | |
| #include "cocos2d.h" | |
| USING_NS_CC; | |
| // not really useful, but I like clean default constructors | |
| CCShake::CCShake() : m_strength_x(0), m_strength_y(0), m_initial_x(0), m_initial_y(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CCImage* img = new CCImage(); | |
| img->initWithImageFile("A4.png"); | |
| unsigned char* data = new unsigned char[img->getDataLen()*4]; | |
| CCLOG("data len %d", img->getDataLen()); | |
| data = img->getData(); | |
| for(int i = 0; i < img->getWidth(); i++) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ResourcesData = require("data.ResourcesData") | |
| local scheduler = require("framework.scheduler") | |
| local Bing_ganPhysics = require("data.bing_ganQuick") | |
| local ChipmunkTestScene = class("ChipmunkTestScene", function() | |
| return display.newScene("ChipmunkTestScene") | |
| end) | |
| local GRAVITY = -200 | |
| local COIN_MASS = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- LUA协程 | |
| -- http://my.oschina.net/wangxuanyihaha/blog/186401 | |
| -- coroutine.create(f) | |
| -- 函数参数[接受单个参数,这个参数为coroutine的主函数] | |
| -- 函数返回值[返回一个thread对象] | |
| -- 函数作用[创建一个新的协程,协程的主函数定义了该协程内的任务流程] | |
| -- coroutine.resume(co, [, var1, ...]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Card::flipAction() { | |
| CCSize winSize = CCDirector::sharedDirector()->getWinSize(); | |
| CCSprite* card = CCSprite::spriteWithFile("card_face.png"); | |
| card->setPosition(ccp(winSize.width/2, winSize.height/2)); | |
| this->addChild(card, CARD_FACE_TAG, CARD_FACE_TAG); | |
| card->setVisible(false); | |
| CCSprite* card2 = CCSprite::spriteWithFile("card.png"); | |
| card2->setPosition(card->getPosition()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "GameObject.h" | |
| #import "LoadingScene.h" | |
| #import "ClassicGameScene.h" | |
| #import "MainMenuScene.h" | |
| @implementation LoadingScene | |
| + (id)sceneWithTargetScene:(TargetScenes)target { | |
| return [[[self alloc] initWithTargetScene:target] autorelease]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #import "cocos2d.h" | |
| typedef enum { | |
| MainMenuTargetScene, | |
| ClassicTargetScene, | |
| }TargetScenes; | |
| @interface LoadingScene : CCScene { | |
| TargetScenes targetScene; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSMutableArray *frames = [NSMutableArray arrayWithCapacity:4]; | |
| for(int i = 0; i < 4; i++){ | |
| CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"lampMenuAni%d.png",i]]; | |
| [frames addObject:frame]; | |
| } | |
| CCAnimation *myAnimation = [CCAnimation animationWithSpriteFrames:frames delay:0.15f]; | |
| id animate = [CCAnimate actionWithAnimation:myAnimation]; | |
| id repeat = [CCRepeatForever actionWithAction:animate]; | |
| [sprite runAction:repeat]; |