Component getting is now done properly in RenderingSystem
This commit is contained in:
parent
8d127a715b
commit
eff6647704
@ -1,5 +1,6 @@
|
|||||||
package com.saltosion.gladiator.systems;
|
package com.saltosion.gladiator.systems;
|
||||||
|
|
||||||
|
import com.badlogic.ashley.core.ComponentMapper;
|
||||||
import com.badlogic.ashley.core.Engine;
|
import com.badlogic.ashley.core.Engine;
|
||||||
import com.badlogic.ashley.core.Entity;
|
import com.badlogic.ashley.core.Entity;
|
||||||
import com.badlogic.ashley.core.EntitySystem;
|
import com.badlogic.ashley.core.EntitySystem;
|
||||||
@ -16,6 +17,8 @@ import com.saltosion.gladiator.components.CRenderedObject;
|
|||||||
|
|
||||||
public class RenderingSystem extends EntitySystem {
|
public class RenderingSystem extends EntitySystem {
|
||||||
|
|
||||||
|
private ComponentMapper<CRenderedObject> rom = ComponentMapper.getFor(CRenderedObject.class);
|
||||||
|
private ComponentMapper<CPosition> pm = ComponentMapper.getFor(CPosition.class);
|
||||||
private ImmutableArray<Entity> entities;
|
private ImmutableArray<Entity> entities;
|
||||||
|
|
||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
@ -44,12 +47,12 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
||||||
for (int i=0; i<entities.size(); i++) {
|
for (int i=0; i<entities.size(); i++) {
|
||||||
CRenderedObject renderedObject = entities.get(i).getComponent(CRenderedObject.class);
|
CRenderedObject renderedObject = rom.get(entities.get(i));
|
||||||
SpriteSequence currSequence = renderedObject.getSequence(renderedObject.getCurrentSequence());
|
SpriteSequence currSequence = renderedObject.getSequence(renderedObject.getCurrentSequence());
|
||||||
int currFrame = (int) Math.floor(renderedObject.getCurrentFrame());
|
int currFrame = (int) Math.floor(renderedObject.getCurrentFrame());
|
||||||
Sprite currSprite = currSequence.getSprite(currFrame);
|
Sprite currSprite = currSequence.getSprite(currFrame);
|
||||||
|
|
||||||
CPosition position = entities.get(i).getComponent(CPosition.class);
|
CPosition position = pm.get(entities.get(i));
|
||||||
|
|
||||||
batch.draw(currSprite, position.x, position.y);
|
batch.draw(currSprite, position.x, position.y);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user