'앱북'에 해당되는 글 4건

  1. 2013.07.02 앱북만들기 1차 연습 트랜스로 페이지 전환, 목차 넣기.
2013.07.02 09:40

앱북만들기 1차 연습 트랜스로 페이지 전환, 목차 넣기.

앱북만들기 1차 연습 소스코드들입니다. 표지 넣기, 첫화면(바로읽기,목차,후원) 생성, 바로읽기 누르면 첫페이지 나오는 것, 오른쪽 터치시 페이지가 넘어가는 효과, 왼쪽 터치시 다시 앞페이지가 나오는 효과까지 만들었습니다. "앱북제작 어렵지 않아요~" 이렇게 말할 수 있을 때까지 화이팅! 하겠습니다. ^^



//

//  HelloWorldLayer.h

//  Trans

//

//  Created by nzin on 13. 6. 20..

//  Copyright __MyCompanyName__ 2013. All rights reserved.

//



// When you import this file, you import all the cocos2d classes

#import "cocos2d.h"


// HelloWorldLayer

@interface HelloWorldLayer : CCLayer

{

}


// returns a CCScene that contains the HelloWorldLayer as the only child

+(CCScene *) scene;


@end


//

//  HelloWorldLayer.m

//  Trans

//

//  Created by nzin on 13. 6. 20..

//  Copyright __MyCompanyName__ 2013. All rights reserved.

//



// Import the interfaces

#import "HelloWorldLayer.h"

#import "GameLayer.h"


// HelloWorldLayer implementation

@implementation HelloWorldLayer



+(CCScene *) scene

{

// 'scene' is an autorelease object.

CCScene *scene = [CCScene node];

// 'layer' is an autorelease object.

HelloWorldLayer *layer = [HelloWorldLayer node];

// add layer as a child to scene

[scene addChild: layer];

// return the scene

return scene;

}


// on "init" you need to initialize your instance

-(id) init

{

// always call "super" init

// Apple recommends to re-assign "self" with the "super" return value

if( (self=[super init])) {

// create and initialize a Label

        

        self.isTouchEnabled = YES;

        

        CCSprite *bg = [CCSprite spriteWithFile:@"0.jpg"];

//        CCSprite *bg = [CCSprite spriteWithFile:@"0.jpg" rect:CGRectMake(0, 0, 320, 480)];

//        [bg setContentSize:CGSizeMake(320, 480)];

        bg.scale = 0.5;  // 표지 사이즈를 절반으로 줄여줌.

        bg.position = ccp(160, 240);

        

        [self addChild:bg];

        CCMenuItemFont *item1 = [CCMenuItemFont itemFromString:@"Start Reading" target:self selector:@selector(goGame)];

        

        CCMenuItemFont *item2 = [CCMenuItemFont itemFromString:@"Contents" target:self selector:@selector(goScore)];

        CCMenuItemFont *item3 = [CCMenuItemFont itemFromString:@"Donation" target:self selector:@selector(goAbout)];

        CCMenu *menu = [CCMenu menuWithItems:item1, item2, item3, nil];

        [menu alignItemsVertically];

        

        [self addChild:menu];


        

}

return self;

}

- (void) goGame{

    id trans = [CCTransitionPageTurn transitionWithDuration:2 scene:[GameLayer scene]];

    [[CCDirector sharedDirector] replaceScene:trans];

    

}


- (void) goScore {

    

}


- (void) goAbout {

    

}


// on "dealloc" you need to release all your retained objects

- (void) dealloc

{

// in case you have something to dealloc, do it in this method

// in this particular example nothing needs to be released.

// cocos2d will automatically release all the children (Label)

// don't forget to call "super dealloc"

    

    NSLog(@"HelloLayer dealloc!!!");

[super dealloc];

}

@end



//

//  GameLayer.h

//  Trans

//

//  Created by nzin on 13. 6. 20..

//  Copyright 2013 __MyCompanyName__. All rights reserved.

//


#import <Foundation/Foundation.h>

#import "cocos2d.h"


@interface GameLayer : CCLayer {

    

}


+(CCScene *) scene;


@end


//

//  GameLayer.m

//  Trans

//

//  Created by nzin on 13. 6. 20..

//  Copyright 2013 __MyCompanyName__. All rights reserved.

//


#import "GameLayer.h"

#import "HelloWorldLayer.h"

#import "GameLayer2.h"


@implementation GameLayer


+(CCScene *) scene {

    

    CCScene *scene = [CCScene node];

    GameLayer *layer = [GameLayer node];

    [scene addChild:layer];

    return scene;

}


- (void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    

    UITouch *touch = [touches anyObject];

    CGPoint touchPoint = [touch locationInView:[touch view]];

    touchPoint = [[CCDirector sharedDirector] convertToGL:touchPoint];

    

    if (touchPoint.x > 160) {

        id trans = [CCTransitionPageTurn transitionWithDuration:3 scene:[GameLayer2 scene]];

        

        [[CCDirector sharedDirector] replaceScene:trans];

    } // x 좌표 스크린 오른쪽을 터치하게 되면 페이지가 넘어감.

    else {

        id trans = [CCTransitionMoveInL transitionWithDuration:3 scene:[HelloWorldLayer scene]];

        

        [[CCDirector sharedDirector] replaceScene:trans];

    } // 스크린 왼쪽을 터치하면 앞페이지가 다시 밀어들어옴.


}


    

    //    id trans = [CCTransitionTurnOffTiles transitionWithDuration:2 scene:[HelloWorldLayer scene]];

//    

//    [[CCDirector sharedDirector] replaceScene:trans];

       //        animate = [CCRepeatForever actionWithAction:animate];

   



- (id) init {

    if (self = [super init]) {

        

        self.isTouchEnabled = YES;

        

        CCSprite *bg = [CCSprite spriteWithFile:@"1.jpg"];

        bg.position = ccp(240, 160);

        [self addChild:bg];

        

                

//        [ani addFrameWithTexture:imageSheet.texture rect:CGRectMake(0, 0, 70, 70)];

//        [ani addFrameWithTexture:imageSheet.texture rect:CGRectMake(70, 0, 70, 70)];

//        [ani addFrameWithTexture:imageSheet.texture rect:CGRectMake(140, 0, 70, 70)];

    

        

//        CCAnimate *animate = [CCAnimate actionWithAnimation:ani];

//        animate = [CCRepeatForever actionWithAction:animate];

//        [item runAction:animate];

    }

    return self;

}


@end













Trackback 0 Comment 0