How to move the entire queue and depict it with canvas.

to complete the following effect diagram, the move: method cannot achieve the desired automatic movement at the speed shift 2,
.png


.png

.
Feb.28,2021

set the timer in the move method. The timer executes the draw method.
in addition, it is not good to create objects all the time in the draw method.
you can create an init method first. After the object has been created, it is stored in the array. The draw method can modify the properties of the object


. I think your structure is very bad, so that your subsequent code can no longer be written.
try to change the way of thinking. A game has a startup entry. We call it Game
and use the timing function in Game. That is, requestAnimation constantly executes the function to be brushed
the two most important methods in the function to be brushed
A update is used to update the location information of all objects in your scene. Update calls the update of all objects in your scene to update the position
a render is used to draw all objects in your scene. Render calls the draw method of all objects to draw the image
then you will find that you need a global data. To manage this information
and abstract the Enemy, If you want more Enemy, new a
https://codeshelper.com/a/11.. You can take a look at this analysis of Wechat's Mini Game jerking off demo. I hope it can help you


recommend https://www.github.com/PengJi.
, which is a canvas 2d rendering library. Small size, powerful, support for drawing, graphics binding time, drag, zoom in and out, and so on.


the amount of call position translation in requestanimationframe is (2 Math.sin (offsetAngle) / 60, 2 Math.cos (offsetAngle) / 60)

Menu