// 新开或切换到另外一个scene,参数依次是 新controller的构造函数,要加载的ccbi文件名
tm.openSceneTest = function (ctor, ccbiFileName, parameter) {
var director = cc.Director.getInstance();
var scene = cc.Scene.create();
firstcontroller = new ctor();
firstcontroller.init(ccbiFileName, parameter);
var getNode = firstcontroller.view.ccbRootNode;
if (getNode)
scene.addChild(getNode);
var mylayer = new dn.testlayer();
mylayer.init();
scene.addChild(mylayer);
tm.log(" addlayer success.");
var runningScene = director.getRunningScene();
if (runningScene === null)
director.runWithScene(scene);
else
director.replaceScene(scene);
};
dn.testlayer = cc.Layer.extend({
ctor:function() {
this._super();
cc.associateWithNative( this, cc.Layer );
cc.registerTargetedDelegate(1, true, this);
},
init: function()
{
this._super();
//var mysize = CC.Director.getInstance().getVisibleSize();
//var Origin = CC.Director.getInstance().getVisibleOrigin();
//var size = cc.Director.getInstance().getWinSize();
dn.log(" init my testlayer");
//if ( !cc.Layer.init() )
//{
// return false;
//}
//this.onEnter();
//this.setContentSize(mysize,1);
return true;
},
onEnter: function()
{
this._super();
//cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate( this,0,false);
//cc.registerTargetedDelegate(0, true, this);
this._touchEnabled=true;
//cc.Layer.onEnter();
},
setParentController: function(parentctrl)
{
this.parentController=parentctrl;
},
onTouchBegan: function(touch, event){
dn.log("Room1Clicked:touch begin...");
var pos = touch.getLocation();//获得触摸的UI坐标
//var pos = cc.Director.getInstance().convertToGL(touchLocation);//转化为opengl坐标
dn.log(pos.x +","+pos.y);
offY = pos.y ;
return true;
},
onTouchesEnded: function(touch, event){
dn.log("Room1Clicked:touch move inside...");
},
onTouchMoved: function(touch,event)
{
dn.log("Room1Clicked:touch move inside...");
var pos = touch.getLocation();//获得触摸的UI坐标
//var pos = cc.Director.getInstance().convertToGL(touchLocation);//转化为opengl坐标
var currentY = firstcontroller.CardTypeInfoCtrl.content_cardtypeinfo.getPositionY();
//currentY = cc.Director.getInstance().convertToGL(currentY);//转化为opengl坐标
dn.log(pos.x +","+pos.y+","+currentY.y);
//if((pos.y - offY) >0) currentY+=10;
//if((pos.y - offY) <0) currentY-=10;
firstcontroller.CardTypeInfoCtrl.content_cardtypeinfo.setPositionY(pos.y - offY+ currentY);
offY = pos.y;
dn.log("Room1Clicked:touch move card...");
//dn.TestCtrl.move(touchLocation.y);
//var pos = CC.Director.sharedDirector().convertToGL(touchLocation);//转化为opengl坐标
//this.content_cardtypeinfo.setPositionY(pos.y);//让精灵移动到该坐标
}