1

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.

AlexYu
  • 87
  • 1
  • 11

1 Answers1

1

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.

MishaVacic
  • 1,812
  • 8
  • 25
  • 29
  • 1
    I get 'ValueError: path '/home/ubuntu/bezier/src/bezier/speedup.f90' cannot be absolute' when I execut 'pip install --upgrade bezier'.I use windows 10 – AlexYu Jul 20 '17 at 04:25
  • I am on Ubuntu 16.04,this is for Linux installation. – MishaVacic Jul 20 '17 at 04:35
  • I get bezier source on gitHub and i download it.so I can install it on windows10.Thank you! – AlexYu Jul 20 '17 at 05:36
  • I figure out.This 'bezier_conf.path1' actually is the 'cocos.path.Bezier'.Because I use cocos2d-x(python),It already include bezier.now I finally find how to use it. – AlexYu Jul 20 '17 at 06:39