var HelloWorldLayer = cc.Layer.extend({
sprite:null,
ctor:function () {
//////////////////////////////
// 1. super init first
this._super();
this.init();
return true;
},
init: function () {
// Create the scrollview
var scrollView = new ccui.ScrollView();
scrollView.setDirection(ccui.ScrollView.DIR_VERTICAL);
scrollView.setTouchEnabled(true);
scrollView.setContentSize(cc.size(280, 150));
scrollView.x = 0;
scrollView.y = cc.winSize.height/2;
this.addChild(scrollView);
var imageView = new ccui.ImageView();
imageView.loadTexture("res/cocosui/ccicon.png");
var innerWidth = scrollView.width;
var innerHeight = scrollView.height + imageView.height;
scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight));
var button = new ccui.Button();
button.setTouchEnabled(true);
button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", "");
button.x = innerWidth / 2;
button.y = scrollView.getInnerContainerSize().height - button.height / 2;
scrollView.addChild(button);
var textButton = new ccui.Button();
textButton.setTouchEnabled(true);
textButton.loadTextures("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png", "");
textButton.setTitleText("Text Button");
textButton.x = innerWidth / 2;
textButton.y = button.getBottomBoundary() - button.height;
scrollView.addChild(textButton);
var button_scale9 = new ccui.Button();
button_scale9.setTouchEnabled(true);
button_scale9.setScale9Enabled(true);
button_scale9.loadTextures("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png", "");
button_scale9.width = 100;
button_scale9.height = 32;
button_scale9.x = innerWidth / 2;
button_scale9.y = textButton.getBottomBoundary() - textButton.height;
scrollView.addChild(button_scale9);
imageView.x = innerWidth / 2;
imageView.y = imageView.height / 2;
scrollView.addChild(imageView);
return true;
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new HelloWorldLayer();
this.addChild(layer);
}
});
测试机器是 小辣椒1s (4.4w) 、 大黄蜂(2.3.7) 、iphone4 ,均有此问题:
按下时出现了往下跳动,在这个例子中大概是一个button的高度。
不知道是不是我用法错了?
已附demo