Hey, Now I d like to draw 3d cube using OrbitCamera,
Here`s myApp.js
`var BgLayer = cc.Layer.extend({
init:function () {
this._super();
var size = cc.Director.getInstance().getWinSize();
this.bg = cc.Sprite.create(“res/bg_grad.jpg”);
this.bg.setPosition(new cc.Point(size.width/2,size.height/2));
this.bg.setContentSize(new cc.Size(size.width/2,size.height/2));
//this.bg.setAnchorPoint(new cc.Point(1,1));
this.addChild(this.bg);
return true;
}
});
var CameraCubeTest = cc.Layer.extend({
init:function () {
this._super();
var size = cc.Director.getInstance().getWinSize();
var cSize = new cc.Size(260, 260);
this.face01 = cc.Sprite.create("res/btn_origin.png");
this.face02 = cc.Sprite.create("res/btn_origin_r.png");
this.face03 = cc.Sprite.create("res/btn_origin_g.png");
this.face04 = cc.Sprite.create("res/btn_origin_b.png");
this.face05 = cc.Sprite.create("res/btn_origin_g.png");
this.face06 = cc.Sprite.create("res/btn_origin_r.png");
this.addChild(this.face01);
this.addChild(this.face02);
this.addChild(this.face03);
this.addChild(this.face04);
// this.addChild(this.face05);
// this.addChild(this.face06);
this.face01.setPosition(size.width/2,size.height/2);
this.face02.setPosition(size.width/2,size.height/2);
this.face03.setPosition(size.width/2-130,size.height/2);
this.face04.setPosition(size.width/2+130,size.height/2);
this.face05.setPosition(size.width/2,size.height/2-130);
this.face06.setPosition(size.width/2,size.height/2+130);
this.face01.setVertexZ(130);
this.face02.setVertexZ(-130);
this.face03.setVertexZ(0);
this.face04.setVertexZ(0);
this.face05.setVertexZ(0);
this.face06.setVertexZ(0);
// var cam02 = this.face02.getCamera();
// var cam03 = this.face03.getCamera();
// var cam04 = this.face04.getCamera();
//var cam05 = this.face03.getCamera();
// cam03.setEyeXYZ(0,0,0);
// cam04.setEyeXYZ(0.1,0,0);
this.face05.runAction(cc.OrbitCamera.create(0.01, 1, 0, 0, 0, 0, 90));
this.face06.runAction(cc.OrbitCamera.create(0.01, 1, 0, 0, 0, 0, 90));
this.face03.runAction(cc.OrbitCamera.create(0.01, 1, 0, 0, 90, 0, 0));
this.face04.runAction(cc.OrbitCamera.create(0.01, 1, 0, 0, 90, 0, 0));
this.setTouchEnabled(true);
return true;
},
onTouchesBegan:function (touches, event) {
var c = cc.OrbitCamera.create(2, 1, 0, 0, 45, 0, 0);
this.runAction(c);
},
onTouchesMoved:function (touches, event) {
},
onTouchesEnded:function (touches, event) {
},
onTouchesCancelled:function (touches, event) {
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var bg = new BgLayer();
var a = new CameraCubeTest();
a.init();
bg.init();
this.addChild(bg);
this.addChild(a);
}
});`
There`s some parts I cannot understand but The big one at the moment is OrbitCamera,
first of all , before I found setEyeXYZ() function, I set very fast Actions to Sprites to change the Camera Eye? Coordination? anyway
I thought It`s working at first but when Starts layer Camera rotation( Using Orbit Camera), Actioned Sprites suddenly get first place,
and Next time I try to set The Eyes (setEyeXYZ()) But same problems poped up in front of my face.
I don`t understand What happened. did I explain clearly? help T-T plaese