Page History
...
최초셋팅법
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://psmon.x-y.net/pscoco/lib/cocos2d-beta2.js"></script> <script src="http://psmon.x-y.net/pscoco/lib/pscoco.js"></script> step.1 위 두 라인을 head 태그안에만 넣어줍니다.(가급적 위 두파일은 복사하여 사용합니다.) step.2 <div id="psmon-demo" style="width: 600px; height: 480px;float: left;"></div> 위 태그를 Body 안에 넣어줍니다. Canvs를 사용할 레이아웃 입니다. step.3 <script type="text/javascript"> var cocoApp=null; cocoApp= new Application('psmon-demo',"gray"); cocoApp.run(); </script> |
...
딜레이애니
Code Block | ||||
---|---|---|---|---|
| ||||
for(var i=0;i<52;i++){ var imgRandom = cocoApp.addImage('assets/frogy1.png', 50,100); imgRandom.moveTo({x:548,y:200-i*0.2,duration:0.5,delay:i*0.1,angle:90,opacity:50,scale:0.5}); } |
...
이벤트처리
Code Block | ||||
---|---|---|---|---|
| ||||
//여기서 마지막 인자값 true,false 는 Layer를 사용할지 여부입니다. 사용하면 이벤트처리가 가능하지만 느려집니다. var img3 = cocoApp.addImage('assets/frogy1.png', 120,200, true); var img4 = cocoApp.addImage('assets/frogy1.png', 200,200, true) img3.onMouseUp = function(event){ img3.position.y=img3.position.y+5; } img4.onMouseUp = function(event){ img4.position.y=img4.position.y+5; } |
...
가속애니메이션
Code Block | ||||
---|---|---|---|---|
| ||||
var easeOpt = { type:"EaseIn", rate:3 }; //or Type EaseInOut var img2 = cocoApp.addImage('assets/frogy1.png', 120,100, false); img2.moveTo({x:495,y:122,duration:3,angle:5, ease:easeOpt }); |
...
경로애니메이션
Code Block | ||||
---|---|---|---|---|
| ||||
var img2 = cocoApp.addImage('assets/ball1.png', 120,100, false); img2.seqTo([ {x:100,y:122,duration:0.3,angle:5 }, {x:250,y:50,duration:0.3,angle:45 }, {x:300,y:300,duration:0.3,angle:90 ,opacity:50,scale:0.5} ]); |
...
스프라이트 애니메이션
Code Block | ||||
---|---|---|---|---|
| ||||
for(var i=0 ; i< 10 ; i++){ _demoRefCount++; var frogAni = new SpriteAnimation({fileName:"assets/ani/flog/frogy",width:700,height:1000,frameCount:15,scale:0.3,repeat:false ,oneDelay:0.03 * (i+1) }); frogAni.position.x=70 * i; frogAni.position.y=150; cocoApp.addChild(frogAni,"frog"+ _demoRefCount ); frogAni.play(); } |
...
커스텀 수학에뮬레이션
Code Block | ||||
---|---|---|---|---|
| ||||
var canvasWidth=600; var canvasHeight=480; for(var i=0;i<100;i++){ var ballImg = cocoApp.addImage('assets/greencircle.png',0,-10,false); ballImg.position.x = Math.round(Math.random() * canvasWidth ); ballImg.position.y = Math.round(Math.random() * canvasHeight ); ballImg.drift = Math.random(); ballImg.speed = Math.round(Math.random() * 5) + 1; ballImg.addSchedule({method:function(){ this.speed = Math.round(Math.random() * 3) + 1; if(this.position.y <= canvasHeight){ this.position.y = this.position.y+this.speed; if(this.position.y > canvasHeight){ this.position.y = -5; } this.position.x+=this.drift; if(this.position.x > canvasWidth){ this.position.x=0 } } },target:ballImg,interval:0,paused:false}); } |
...