ココス楽しー

var res = {
};
var MyLayer = cc.KidspodLayer.extend({
init:function(){
this._super();
this.schedule(this.update);
var size = cc.director.getWinSize();
var pos_x = size.width/2;
var pos_y = size.height/2
var vel_x = 3.5;
var vel_y = 3.5;
var ball = cc.Sprite.create("res/galaxy/ball.png");
ball.setPosition(pos_x,pos_y);
this.addChild(ball);
this.schedule(function(){
pos_x = pos_x + vel_x;
pos_y = pos_y + vel_y;
if( pos_x < 0 || size.width < pos_x )
{
vel_x = -(vel_x);
}
if( pos_y < 0 || size.height < pos_y )
{
vel_y = -(vel_y);
}
ball.setPosition(pos_x,pos_y);
}, 0.01);
return true;
},
update:function(dt){
},
onMouseDown:function(event){
},
onKeyPressed:function(key, event){
},
onTouchBegan:function(touch, event){
},
onAccelerometer:function(accelero, event){
},
});
var MyScene = cc.Scene.extend({
onEnter:function (){
this._super();
var layer = new MyLayer();
layer.init();
this.addChild(layer);
}
});