我想知道如何将精灵从屏幕中心移动到距离屏幕顶部边缘 10 个像素的位置。从而使它看起来像是在向上移动。
到目前为止,这是我的代码
var LoginLayer = cc.Layer.extend({
init:function () {
//////////////////////////////
// 1. super init first
this._super();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// ask director the window size
var size = cc.Director.getInstance().getWinSize();
//Create Background Layer
var background = cc.LayerColor.create( g_Colors.cedarWoodFinish, size.width, size.height);
background.setAnchorPoint( cc.p(0.5,0.5) );
//Create Logo Layer
var logo = cc.Sprite.create(s_logo);
logo.setAnchorPoint(cc.p(0.5, 1));
logo.setPosition(cc.p(size.width / 2, size.height + ((logo.getContentSize().height * logo.getScaleY()) /2)));
logo.setScale(0.5);
//Add Layers To Scene
this.addChild(background);
this.addChild(logo);
var logoMoveUpAnimation = cc.MoveTo.create(2, cc.p(size.width / 2, size.height - 10) );
logo.runAction(logoMoveUpAnimation);
}
});
var LoginScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new LoginLayer();
this.addChild(layer);
layer.init();
}
});