Java Code Examples for master.flame.danmaku.danmaku.util.DanmakuUtils#willHitInDuration()
The following examples show how to use
master.flame.danmaku.danmaku.util.DanmakuUtils#willHitInDuration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DanmakusRetainer.java From letv with Apache License 2.0 | 4 votes |
public void fix(BaseDanmaku drawItem, IDisplayer disp, Verifier verifier) { if (!drawItem.isOutside()) { float topPos = 0.0f; int lines = 0; boolean willHit = (drawItem.isShown() || this.mVisibleDanmakus.isEmpty()) ? false : true; boolean isOutOfVertialEdge = false; boolean shown = drawItem.isShown(); if (!shown) { boolean overwriteInsert; this.mCancelFixingFlag = false; IDanmakuIterator it = this.mVisibleDanmakus.iterator(); BaseDanmaku insertItem = null; BaseDanmaku firstItem = null; BaseDanmaku lastItem = null; BaseDanmaku minRightRow = null; while (!this.mCancelFixingFlag && it.hasNext()) { lines++; BaseDanmaku item = it.next(); if (item == drawItem) { insertItem = item; lastItem = null; shown = true; willHit = false; overwriteInsert = false; break; } if (firstItem == null) { firstItem = item; } if (drawItem.paintHeight + item.getTop() > ((float) disp.getHeight())) { overwriteInsert = true; break; } if (minRightRow == null) { minRightRow = item; } else if (minRightRow.getRight() >= item.getRight()) { minRightRow = item; } willHit = DanmakuUtils.willHitInDuration(disp, item, drawItem, drawItem.getDuration(), drawItem.getTimer().currMillisecond); if (!willHit) { insertItem = item; overwriteInsert = false; break; } lastItem = item; } overwriteInsert = false; boolean checkEdge = true; if (insertItem != null) { if (lastItem != null) { topPos = lastItem.getBottom(); } else { topPos = insertItem.getTop(); } if (insertItem != drawItem) { this.mVisibleDanmakus.removeItem(insertItem); shown = false; } } else if (overwriteInsert && minRightRow != null) { topPos = minRightRow.getTop(); checkEdge = false; shown = false; } else if (lastItem != null) { topPos = lastItem.getBottom(); willHit = false; } else if (firstItem != null) { topPos = firstItem.getTop(); this.mVisibleDanmakus.removeItem(firstItem); shown = false; } else { topPos = 0.0f; } if (checkEdge) { isOutOfVertialEdge = isOutVerticalEdge(overwriteInsert, drawItem, disp, topPos, firstItem, lastItem); } if (isOutOfVertialEdge) { topPos = 0.0f; willHit = true; } if (topPos == 0.0f) { shown = false; } } if (verifier == null || !verifier.skipLayout(drawItem, topPos, lines, willHit)) { if (isOutOfVertialEdge) { clear(); } drawItem.layout(disp, drawItem.getLeft(), topPos); if (!shown) { this.mVisibleDanmakus.addItem(drawItem); } } } }
Example 2
Source File: DanmakusRetainer.java From letv with Apache License 2.0 | 4 votes |
public void fix(BaseDanmaku drawItem, IDisplayer disp, Verifier verifier) { if (!drawItem.isOutside()) { boolean shown = drawItem.isShown(); float topPos = drawItem.getTop(); int lines = 0; boolean willHit = (drawItem.isShown() || this.mVisibleDanmakus.isEmpty()) ? false : true; boolean isOutOfVerticalEdge = false; if (topPos < 0.0f) { topPos = ((float) disp.getHeight()) - drawItem.paintHeight; } BaseDanmaku removeItem = null; BaseDanmaku firstItem = null; if (!shown) { this.mCancelFixingFlag = false; IDanmakuIterator it = this.mVisibleDanmakus.iterator(); while (!this.mCancelFixingFlag && it.hasNext()) { lines++; BaseDanmaku item = it.next(); if (item == drawItem) { removeItem = null; willHit = false; break; } if (firstItem == null) { firstItem = item; if (firstItem.getBottom() != ((float) disp.getHeight())) { break; } } if (topPos < 0.0f) { removeItem = null; break; } willHit = DanmakuUtils.willHitInDuration(disp, item, drawItem, drawItem.getDuration(), drawItem.getTimer().currMillisecond); if (!willHit) { removeItem = item; break; } topPos = item.getTop() - drawItem.paintHeight; } isOutOfVerticalEdge = isOutVerticalEdge(false, drawItem, disp, topPos, firstItem, null); if (isOutOfVerticalEdge) { topPos = ((float) disp.getHeight()) - drawItem.paintHeight; willHit = true; } else if (topPos >= 0.0f) { willHit = false; } } if (verifier == null || !verifier.skipLayout(drawItem, topPos, lines, willHit)) { if (isOutOfVerticalEdge) { clear(); } drawItem.layout(disp, drawItem.getLeft(), topPos); if (!shown) { this.mVisibleDanmakus.removeItem(removeItem); this.mVisibleDanmakus.addItem(drawItem); } } } }