Search code examples
pythoncocos2d-python

What is bezier_conf.path1 in cocos2d(python)


I'm learning cocos2d(python).When i watch cocos2d Documentation on webpage(cocos2d documentation).There are some code as follows:

action = Bezier(bezier_conf.path1, 5)   # Moves the sprite using the
sprite.do(action)                       # bezier path 'bezier_conf.path1'
                                      # in 5 seconds

and no more code.I don't understande what is 'bezier_conf.path1' and what value is i used to defined it.


Solution

  • You need to install package

    pip install --upgrade bezier
    

    Small example

    import numpy as np
    import bezier
    
    n1 = np.array([[0.0, 1.0],[1.5, 1.0],[1.0, 0.0],])
    n2 = np.array([[0.0, 0.0],[1.0, 1.0],[1.0, 2.5],])
    curve1 = bezier.Curve(n1, degree=2)
    curve2 = bezier.Curve.from_nodes(n2)
    intersections = curve1.intersect(curve2)
    
    print (intersections)
    

    The intersection between two curves is calculated in this example.You need to import bezier for your code.