QHDanumuDemo
QHDanumuDemo copied to clipboard
航道弹幕碰撞检测有问题
CGFloat timeE = newDanmuL.currentRightX/newDanmuL.speed;
if (timeE <= durationTime) {
return NO;
}
这里新的lable没有DanmuState属性,默认为0,所以根据
- (CGFloat)currentRightX {
switch (self.danmuState) {
case DanmuStateStop: {
_currentRightX = CGRectGetMaxX(self.frame) - _superView.frame.size.width;
break;
}
case DanmuStateAnimationing: {
CALayer *layer = self.layer;
_currentRightX = _originalX;
if (layer.presentationLayer)
_currentRightX = ((CALayer *)layer.presentationLayer).frame.origin.x + self.frame.size.width;
_currentRightX -= _superView.frame.size.width;
break;
}
case DanmuStateFinish: {
_currentRightX = -_superView.frame.size.width;
break;
}
default: {
break;
}
}
return _currentRightX;
}
typedef NS_ENUM(NSUInteger, DanmuState) {
DanmuStateStop = 1,
DanmuStateAnimationing,
DanmuStateFinish
};
newDanmuL.currentRightX一直为0,最上面的代码恒retrun NO,后面的检测没有意义,弹幕正常显示只是因为后面的寻找缓冲区航道完成的。
这样的问题在于弹幕字体很小或很短时上面的航道空间还很大的时候弹幕不会优先显示在上面,而会像阶梯一样采用下面的航道。
我看看哈,感谢告知
搭个车... 想邀请Repo作者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍: http://t.cn/Ai1vLcCU http://t.cn/Ai1vLcCG http://t.cn/Ai1vLcCA