<>1. Syllabus

* String splicing （+） Learning and Application
* Application of coordinate transformation in aircraft war game
<>2.1 String splicing

* stay JS Use in “+" Number , Connection string , variable , Numerical value, etc .
<>2.2 Show the number of friends on the warning box

* Show the number of friends on the warning box , The display effect is as follows

* Declare variables friends Number of friends , Display on warning box “ The number of my friends is ：7", Using string concatenators "+" , The code is as follows ‘ var friends = 7;
alert(" The number of my friends is :" +friends);
<>2.3 Show your age on the warning box

* Declare variables age, And assigned to their own age , The code is as follows : var age = 23;
* Display on warning box “ My age is ：23”, Using string concatenators “+”, The code is as follows ： alert(" My age " + age);
* The display effect is as follows

<>2.4 Show the score of the aircraft war game on the canvas

* Declare variables score, And assigned to the score of the game , The code is as follows ： var score = 95;
* Declare variables x, And assign the value of X coordinate , The code is as follows ： var x = 50;
* Declare variables y, And assign the value of Y coordinate , The code is as follows ： var y = 50;
* use ctx Of font Property to set the size and font of the text , The code is as follows ： ctx.font = "30px Microsoft YaHei ";
* Show on canvas “ fraction ：98", use fillText Methods and string concatenators "+", The code is as follows : var score = 95; var x = 50; var
y= 50; ctx.font = "30px Microsoft YaHei "; ctx.fillText(" fraction ：" + score,x,y);
* The code runs as follows

<>3.1 Change of coordinates

*
Look at the picture below , Villains from A Point move to B spot , How do coordinates change ?

*
As can be seen from the figure , Villains from A Point move to B spot , coordinate X Value increased 4, Y The value did not change .

*
Look at the picture below , Villains from A Point move to B spot , How do coordinates change ?

As can be seen from the figure , Villains from A Point move to B spot , The coordinate Han value has been increased 3, y Value increased 2 .

<> Background and aircraft movement

* What is the coordinate change law of the background and the aircraft at the same time ： Background and aircraft X The values of the coordinates do not change ,Y The values of the coordinates are increasing ;
* If you want the plane to move faster than the background , At the same time , Aircraft Y Coordinate value-added ratio of background Y The added value of coordinates is large .
* The code for background and aircraft movement is as follows （ among ：x1,y1 Coordinates representing the background ;x,y Represents the coordinates of the aircraft ）: var x1 = 0; var y1 = 0; var x =
200; var y = 0; setInterval(function(){ ctx.drawImage(background, x1, y1); y1=y1
+1; ctx.drawlmage(enemy, x, y); y=y+3; },10);

Technology
Daily Recommendation
views 2