Warning! This page is still in the works.


cc.fillStyle = "color"
cc.beginPath()
cc.arc(x, y, r, 0*Math.PI, 2*Math.PI)
cc.fill()

cc.fillStyle = "color"
cc.fillRect(x, y, w, h)

In regards to the above, please note the following:

  • The 'x' and 'y' tell the computer where to start drawing shapes.
  • Although x and y can be a number, it can also be a variable.
  • Using variables instead of numbers for your x and y coordinates means you can set a continuous equation for your shape:
  • 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)

    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