This file contains 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)turnCard | |
{ | |
if ([self isFaceUp]) { | |
[self flipHide]; | |
self.faceUp = NO; | |
} else { | |
self.faceUp = YES; | |
[self flipReveal]; | |
} | |
} |
This file contains 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
#pragma mark - touch delegate | |
- (CGPoint)locationFromTouch:(UITouch *)touch | |
{ | |
CGPoint touchLocation = [touch locationInView:[touch view]]; | |
return [[CCDirector sharedDirector]convertToGL:touchLocation]; | |
} | |
- (BOOL)containsTouchLocation:(UITouch *)touch | |
{ | |
CGRect selfRect = CGRectMake(self.position.x, self.position.y, self.contentSize.width, self.contentSize.height); |
This file contains 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
// 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 { | |
} |
This file contains 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]; |
This file contains 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 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 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 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 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 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++) | |
{ |
OlderNewer