短Answer.-
阶段要求所有演员的绘制方法。
长的答案只是completeness.-
阶段要求绘制它的(根)集团的方法。
Stage.java -L118
public void draw() {
Camera camera = viewport.getCamera();
camera.update();
if (!root.isVisible()) return;
Batch batch = this.batch;
if (batch != null) {
batch.setProjectionMatrix(camera.combined);
batch.begin();
root.draw(batch, 1);
batch.end();
}
if (debug) drawDebug();
}
和根集团调用其drawChildren方法。
Group.java -L56
public void draw (Batch batch, float parentAlpha) {
if (transform) applyTransform(batch, computeTransform());
drawChildren(batch, parentAlpha);
if (transform) resetTransform(batch);
}
这是谁调用所有的小演员画法的方法。
Group.java -L66
protected void drawChildren (Batch batch, float parentAlpha) {
parentAlpha *= this.color.a;
SnapshotArray<Actor> children = this.children;
Actor[] actors = children.begin();
Rectangle cullingArea = this.cullingArea;
if (cullingArea != null) {
// Draw children only if inside culling area.
float cullLeft = cullingArea.x;
float cullRight = cullLeft + cullingArea.width;
float cullBottom = cullingArea.y;
float cullTop = cullBottom + cullingArea.height;
if (transform) {
for (int i = 0, n = children.size; i < n; i++) {
Actor child = actors[i];
if (!child.isVisible()) continue;
float cx = child.x, cy = child.y;
if (cx <= cullRight && cy <= cullTop && cx + child.width >= cullLeft && cy + child.height >= cullBottom)
child.draw(batch, parentAlpha);
}
} else {
// No transform for this group, offset each child.
float offsetX = x, offsetY = y;
x = 0;
y = 0;
for (int i = 0, n = children.size; i < n; i++) {
Actor child = actors[i];
if (!child.isVisible()) continue;
float cx = child.x, cy = child.y;
if (cx <= cullRight && cy <= cullTop && cx + child.width >= cullLeft && cy + child.height >= cullBottom) {
child.x = cx + offsetX;
child.y = cy + offsetY;
child.draw(batch, parentAlpha);
child.x = cx;
child.y = cy;
}
}
x = offsetX;
y = offsetY;
}
} else {
// No culling, draw all children.
if (transform) {
for (int i = 0, n = children.size; i < n; i++) {
Actor child = actors[i];
if (!child.isVisible()) continue;
child.draw(batch, parentAlpha);
}
} else {
// No transform for this group, offset each child.
float offsetX = x, offsetY = y;
x = 0;
y = 0;
for (int i = 0, n = children.size; i < n; i++) {
Actor child = actors[i];
if (!child.isVisible()) continue;
float cx = child.x, cy = child.y;
child.x = cx + offsetX;
child.y = cy + offsetY;
child.draw(batch, parentAlpha);
child.x = cx;
child.y = cy;
}
x = offsetX;
y = offsetY;
}
}
children.end();
}
@Alexķ感谢适应英语 – 2014-10-05 13:19:04
Render方法是从渲染在后台运行的线程调用。 – Veljko 2014-10-05 16:41:59
Veljko要求回答 – 2014-10-06 17:05:09