this code was working using cocos creator 2.4 / JS.
how to convert this code to typescript on cocos creator 3.0
What is the width method in typescript?
…
Loop the movement of a node on x axis
i Found Good solutions for that it can be solved in two ways to move a node or sprite on x axis.
@type(Canvas)
_framesize : null;
private CocosLogo: Vec3 = new Vec3(0,-260,0);
private _frameSize: Size;
constructor () {
super();
this._frameSize = new Size(480, 320);
}
public getFrameSize (): Size {
return new Size(this._frameSize.width, this._frameSize.height);
}
update (deltaTime: number) {
if (this.CocosLogo.x < -(this._frameSize.width/2) - this._frameSize.width/2 ){
this.CocosLogo.x = this._frameSize.width
}
}
or
if (this.CocosLogo.x < -(490)){
this.CocosLogo.x = 558;
}