cc.Class({
extends: cc.Component,
properties: {
bg:cc.Node,
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
this.bg.runAction(cc.sequence(cc.moveBy(1, cc.p(-1136, 0))).repeatForever());
this.node.runAction(cc.sequence(cc.delayTime(0.2),cc.callFunc(function(){
for(var i=0,lenI=200;i<lenI;i++)
{
var pfbEnemy = new cc.Node();
pfbEnemy.parent=this.node;
}
}.bind(this))).repeatForever());
},
update:function(){
if (this.bg.getPosition().x <= -1136) {
this.bg.setPositionX(0);
}
console.log("this.bg.getPositionX:"+this.bg.getPositionX());
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
bg随便弄个1136 宽的layer 铺满屏幕 就可以了 然后不停的插入node,发现bg移动越来越慢,隔个20s左右你会发现log中的bg的坐标固定了!!!!!背景全黑了
难道new cc.Node不该这样写了吗

