问题描述
我正在使用COCOS2D开发游戏.在我的游戏中,有4个点,每个点通过一条线相互连接.当用户移动该点时,线条随该点移动.在移动时,如果一条线与另一条线相交,则线颜色应变为红色.我该怎么做,即线成红色?以及如何检测两条线的交点?谁能帮助我解决COCOS2D中的交叉点问题?
I am developing a game using COCOS2D.In my game, there are 4 points, each point is connected with each other by one line.When user moves the point, the lines move with the point.At the time of moving, if a line intersects with another line, line color should become red.How can I do this, i.e. line to colored red?And how to detect the intersection of two lines?Can anyone help me to solve this intersection problem in COCOS2D?
推荐答案
您可以使用cocos2d提供的此功能检测两个线段是否相交.
You can detect whether 2 segments intersect using this function provided by cocos2d.
BOOL ccpSegmentIntersect(CGPoint A,CGPoint B,CGPoint C,CGPoint D)
BOOL ccpSegmentIntersect(CGPoint A, CGPoint B, CGPoint C, CGPoint D)
这篇关于在COCOS2D中的2条线之间的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!