Website:
http://cn.cocos2d-x.org/
Document:
Http://cn.cocos2d-x.org/doc/jsdoc/symbols/cc.Node.html#onEnter
Http://www.cocos2d-x.org/reference/html5-js/V3.0/index.html
=======================================================
/* Properties */
if (!true) {
var sprite1 = new CC. Sprite (Res. SP1);
var sprite2 = new CC. Sprite (Res. SP1);
Sprite1.attr ({
x:200,//Location
Y:200,
anchorx:0.5,//Anchor Point
anchory:0.5,
opacity:255//Transparency [0-255]
});
Sprite1.scale = 0.5; Zoom ratio
This.addchild (sprite1, 1, 1);
Print property values
Cc.log ("x =" + sprite1.x, "y =" + sprite1.y);
Cc.log ("Anchorx =" + Sprite1.anchorx, "anchory =" + sprite1.anchory);
Print property values
//....................................................................................................................... ......................
Sprite2.attr ({
x:400,//Location
Y:200,
anchorx:0.5,//Anchor Point
anchory:0.5,
opacity:255//Transparency
});
Sprite2.scale = 0.5; Zoom ratio
Sprite2.scalex = 0.5; Width scaling
This.addchild (Sprite2, 1, 2);
Sprite2.rotation = 40;//Rotated 40 degrees
Sprite2.rotationx = 40;//x axis Rotated 40 degrees, Y axis same
Sprite2.color = Cc.color (134,232,110);//Set node's color
Sprite2.visible = true; is displayed
Print property values
Cc.log ("tag =" + Sprite2.gettag ());
Cc.log ("x =" + sprite2.x, "y =" + sprite2.y);
Cc.log ("Anchorx =" + Sprite2.anchorx, "anchory =" + sprite2.anchory);
Cc.log ("color =" + Sprite2.getcolor ());//rgb value
Print property values
}
Action
if (true) {
var sprite1 = new CC. Sprite (Res. SP1);
Sprite1.attr ({
x:200,//Location
Y:200,
scale:0.5
});
This.addchild (sprite1, 2);
var actionary = [];
MoveTo, move to new coordinates
var moveto = new CC. MoveTo (1, CC.P (400, 200));
Sprite1.runaction (MoveTo);
Actionary.push (MoveTo);
Moveby,x, y relative increase
var moveby = new CC. Moveby (1, CC.P (100, 100));
Sprite1.runaction (Moveby);
Actionary.push (Moveby);
Scaleto zoom in and zoom out
var scaleto = new CC. Scaleto (1, 2);
var Scaleto2 = new CC. Scaleto (1, 1);
var rp = new CC. RepeatForever (Cc.sequence (Scaleto, Scaleto2));
Sprite1.runaction (RP);
Sprite1.runaction (Cc.sequence (Scaleto, Scaleto2). RepeatForever ());
Scaleby
var scaleby = new CC. Scaleby (1, 2);
Sprite1.runaction (Scaleby);
Fadeto, transparency 0-255
var fadeto = new CC. FadeTo (1, 200);
Sprite1.runaction (Fadeto);
Fadein
var Fadein = new CC. FadeIn (3, 255);
sprite1.opacity = 0;
Sprite1.runaction (Fadein);
Fadeout
var fadeout = new CC. FadeOut (1, 1);
Sprite1.runaction (fadeout);
Bezierto, PARABOLIC
var Bézier = [CC.P (CC.P), CC.P (600, 200)];
var Bezierto = new CC. Bezierto (2, Bézier);
Sprite1.runaction (Bezierto);
Rotateto, swivel
var rotateto = new CC. Rotateto (2, 90);
Sprite1.runaction (Rotateto);
Rotateby
var rotateby = new CC. Rotateby (2, RepeatForever).
Sprite1.runaction (Rotateby);
Sprite1.runaction (Cc.spawn (Bezierto, Rotateby));
Fllow, following nodes
var childnode = new CC. Sprite (Res. Closenormal_png);
Childnode.scale = 1;
Childnode.attr ({
X:100,
y:100
// });
This.addchild (Childnode, 2);
var followaction = new CC. Follow (sprite1);
Childnode.runaction (followaction);
Childnode.runaction (Cc.follow (sprite1, cc.rect (0, 0, 100, 100)));
Blink flashing
var blink = new CC. Blink (10, 100);
Sprite1.runaction (Blink);
SetTimeout (function () {
Blink.stop ();//3 seconds after stop flashing
}, 3000);
Sprite1.runaction (Cc.sequence (actionary));
Properties and actions of the COCO2D-JS node