Skip to content

Instantly share code, notes, and snippets.

View dabing1022's full-sized avatar
👨‍💻
Focusing

ChildhoodAndy dabing1022

👨‍💻
Focusing
View GitHub Profile
@dabing1022
dabing1022 / UIKitBox2dView.h
Last active August 29, 2015 14:01
UIKitBox2dView
#import <UIKit/UIKit.h>
#import <Box2D/Box2D.h>
@interface ViewController : UIViewController <UIAccelerometerDelegate> {
b2World* world;
NSTimer *tickTimer;
b2Vec2 gravity;
}
// 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)
@dabing1022
dabing1022 / changeColor.cpp
Created April 22, 2014 09:28
将图片更改为纯色
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++)
{
@dabing1022
dabing1022 / physics-test.lua
Last active August 29, 2015 13:58
quick-cocos2dx-physics-test(2.2.1rc)
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
@dabing1022
dabing1022 / LuaCoroutine.lua
Created December 21, 2013 06:59
理解LUA协程
-- LUA协程
-- http://my.oschina.net/wangxuanyihaha/blog/186401
-- coroutine.create(f)
-- 函数参数[接受单个参数,这个参数为coroutine的主函数]
-- 函数返回值[返回一个thread对象]
-- 函数作用[创建一个新的协程,协程的主函数定义了该协程内的任务流程]
-- coroutine.resume(co, [, var1, ...])
@dabing1022
dabing1022 / CardFlip
Created November 21, 2013 15:09 — forked from syuhari/CardFlip
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());
#import "GameObject.h"
#import "LoadingScene.h"
#import "ClassicGameScene.h"
#import "MainMenuScene.h"
@implementation LoadingScene
+ (id)sceneWithTargetScene:(TargetScenes)target {
return [[[self alloc] initWithTargetScene:target] autorelease];
#import <Foundation/Foundation.h>
#import "cocos2d.h"
typedef enum {
MainMenuTargetScene,
ClassicTargetScene,
}TargetScenes;
@interface LoadingScene : CCScene {
TargetScenes targetScene;
@dabing1022
dabing1022 / CCAnimationAbout.m
Last active December 17, 2015 08:49
CCAnimationAbout
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];
// Feel free to use. MIT License
#import <Foundation/Foundation.h>
#import "cocos2d.h"
// Layer that will just capture any touch events on it
@interface OpaqueLayer : CCLayerColor {
}