html52017. 2. 23. 12:13
var game = cc.Layer.extend({
  init:function () {
    this._super();

    backgroundLayer =  cc.LayerColor.create(new cc.Color(40,40,40,255), 320, 480);

    var target = cc.Sprite.create("resources/doge.png"); /*child to clip*/
    var mask = cc.Sprite.create("resources/doge-mask.png"); /*mask*/

    var maskedFill = new cc.ClippingNode(mask);
    maskedFill.setAlphaThreshold(0.9);
    maskedFill.addChild(target);
    maskedFill.setPosition(144, 224);

    backgroundLayer.addChild(maskedFill,0);
    this.addChild(backgroundLayer);

  }
});


Posted by 차돌이라네
html52016. 7. 27. 13:06

# html5 로 앱을 만들기 위해 jsb방식으로 할 경우 XMLHttpRequest 로 xml 파일 로드가 안되는 경우가 발생한다.


#웹에서 실행하면 잘 되는데.....


#그래서, 다른 방법 모색


1. xml 파일을 jsb 파일로 변경


2. var str = jsb.fileUtils.getStringFromFile("src/data/stage/stage_" + this.stageNum + ".json");

  var temp = JSON.parse(str);


Posted by 차돌이라네
html52015. 10. 20. 18:02

*안드로이드 App 개발시 cc.LabelTTF 의 폰트 적용 방법

-네이티브 앱일 경우와 html5 웹으로 보여 질때를 구분 하여, 앱일 경우에는 폰트의 이름과 확장자까지 기입을

해 준다.


if (cc.sys.isNative)

{

    this.quiz_txt = cc.LabelTTF.create("게임 시작", "res/fonts/HYBDAM.ttf", 40, cc.size(320, 110), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER);

} else {

    this.quiz_txt = cc.LabelTTF.create("게임 시작", "HYBDAM", 40, cc.size(320, 110), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER);

}

this.quiz_txt.setColor(cc.color(255,255,255));

this.quiz_txt.enableStroke(cc.color(0,110,208), 4);

this.quiz_txt.x = 500;

this.quiz_txt.y = 300;

this.addChild(this.quiz_txt);

Posted by 차돌이라네
html52014. 2. 19. 13:12

 

# 애니메이션 스프라이트를 MenuItemSprite 에 적용 하여 버튼을 만들자

1.  우선 애니메이션 스프라이트인 StartButtonSprite 파일을 만든다. 꼭, ctor 함수 부분에 이미지 한장 짜리 스프라이트를

배치 한 후 애니메이션을 실행 해야 한다.

var StartButtonSprite = cc.Sprite.extend
({
    ctor:function()
    {
        this._super();
        cc.associateWithNative(this, cc.Sprite);

        //만들어 놓은 StartButtonBasic 스프라이트
        var pFrame = cc.SpriteFrameCache.getInstance().getSpriteFrame("StartButtonBasic");
        this.initWithSpriteFrame(pFrame);
        this.play();
        return true;
},

    play:function()
    {      

       //만들어 놓은 StartButtonBasic 스프라이트
        var animation = cc.AnimationCache.getInstance().getAnimation("StartButton");
        var animate = cc.Animate.create(animation);
        this.runAction(cc.RepeatForever.create(animate));
    }

});

 

2. MenuItemSprite 만들기

        var startBtnImg = new StartButtonSprite();
        var menuItem = cc.MenuItemSprite.create(startBtnImg, null, this.goGame, this);
        this.startBtn = cc.Menu.create(menuItem);
        this.startBtn.setPosition(cc.p(GD.WW*0.5, 50));
        this.addChild(this.startBtn);

 

 

 

 

Posted by 차돌이라네