cc.fillStyle = "color"
cc.beginPath()
cc.arc(x, y, r, 0*Math.PI, 2*Math.PI)
cc.fill()
cc.beginPath()
cc.arc(x, y, r, 0*Math.PI, 2*Math.PI)
cc.fill()
cc.fillStyle = "color"
cc.fillRect(x, y, w, h)
cc.fillRect(x, y, w, h)
In regards to the above, please note the following:
- For rectangles, the upper left corner of it's drawn first.
- For circles, the middle is where it's drawn first.
x1 = x1 + (put any number here) // The number given will determine the speed of the shape. //
However, please note that x1 needs a value to be equal to. In initialize(), add the following:
x1 = (put any number here)
Warning! Note that the width of the entire screen is 500 and the height, 600. X and Y variables exceeding the width/height of canvas means that the shape will not be seen.
cc.fillStyle = "black"
cc.fillRect(x1,50,20,20)
cc.fillRect(x1,50,20,20)
The Next Step
Create a speed variable in initialize(). The number should be the same as whatever you are adding subtracting in your update line.
If you have in repeatingForever():
x1 = x1 + 3
Then in initialize(), you should add:
x1speed = 3
In repeatingForever(), change your "update" line so that it uses the speed variable you created.
x1 = x1 + 3
becomes...
x1 = x1 + q1speed