Hi!
I’m a very newbie on COCOS2D-html5 and I’m trying to animate a cc.LabelTTF. I’m using the same template of the HelloWorld example, the difference is on the Layer definition. That is:
(function () {
var d = document;
var c = {
COCOS2D_DEBUG:2, //0 to turn debug off, 1 for basic debug, and 2 for full debug
box2d:false,
showFPS:false,
frameRate:60,
tag:‘gameCanvas’, //the dom element to run cocos2d on
engineDir:‘libs/cocos2d/’,
//SingleEngineFile:‘’,
appFiles:[
’src/resource.js’,
‘src/xxxxx.js’ //->add your js filename
]
};
Notice2:
all resource name were wrote into resource.js .
Notice1: Yes, the file is credits.js. The Label is showed in the canvas, but it doesn’t move with runAction.
Notice2: There aren’t resources in my project for now. Just a label…
Can you please try the project with your browser? What I’m trying to do is just to show a layer with a label that moves from the bottom to the center of the screen and then replace this layer with a different one, using a different label.
Hi!
I’m a very newbie on COCOS2D-html5 and I’m trying to animate a cc.LabelTTF. I’m using the same template of the HelloWorld example, the difference is on the Layer definition. That is:
>
`var creditLayer = cc.Layer.extend({
creditLabel:null,
var creditsScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layerCreated = new creditLayer();
layerCreated.init();
this.addChild(layerCreated);
var layerProgrammed = new creditLayer();
layerProgrammed.init();
this.scheduleOnce(function() {
this.removeChild(layerCreated);
this.addChild(layerProgrammed);
}, 3.0);
},
I’m using the last version of FF (16) and it doesn’t work for me. Also tryed with Chrome, but again MoveTo doesn’t work. I tryed with MoveBy, I tryed using a Sprite. The actions are not performed… I’m thinking about a bug, but if so why the tests work?
Anyway I should try with IE…
Hi, please remove the define of onEnter and onExit on creditLayer or add this.*super in it.
Here is the code which works well.
<pre>
var creditLayer = cc.Layer.extend {
this.*super();
var size = cc.Director.getInstance().getWinSize();
this.creditLabel = cc.LabelTTF.create(text, “Arial”, 38);
this.creditLabel.setAnchorPoint(cc.p(0.5,0.5));
this.creditLabel.setPosition(cc.p(size.width / 2, 0));
this.addChild(this.creditLabel, 5);
var MoveToAction = cc.MoveTo.create(2.5, cc.p(size.width / 2, size.height / 2));
this.creditLabel.runAction(MoveToAction); //this.creditLabel.scheduleUpdate();
this.setTouchEnabled(true);
return true;
}
});
var MyScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new creditLayer();
this.addChild(layer);
layer.init(‘test for Matteo Bucchi’);
}
});