本文整理汇总了Java中com.badlogic.ashley.core.Engine类的典型用法代码示例。如果您正苦于以下问题:Java Engine类的具体用法?Java Engine怎么用?Java Engine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Engine类属于com.badlogic.ashley.core包,在下文中一共展示了Engine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDestroyed
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void onEntityDestroyed(Engine engine, Entity entity, Entity source) {
IdComponent bulletId = idMapper.get(source);
// TODO: 06-Apr-17 Improve how we find the source
if (bulletId != null) {
for (Entity player : players) {
IdComponent playerId = idMapper.get(player);
if (Objects.equals(playerId.participantId, bulletId.participantId)) {
if (player.isScheduledForRemoval()) return;
ScoreComponent scoreComponent = scoreMapper.get(player);
int oldScore = scoreComponent.score;
scoreComponent.score += SCORE_INCREASE;
notifyListeners(engine, player, oldScore);
return;
}
}
}
// TODO: 05-Apr-17 calculate rounds won
}
示例2: PlayState
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
public PlayState(GameStateManager gsm) {
super(gsm);
Assets.loadGameStageAssets();
Engine ashleyEngine = new Engine();
LevelManager.loadLevel("maps/simple-map.tmx");
_renderer = new OrthogonalTiledMapRenderer(LevelManager.tiledMap);
_gameCamera = new OrthographicCamera();
EntityFactory entityFactory = new EntityFactory(ashleyEngine);
InputHandler inputhandler = new InputHandler(_gameCamera,entityFactory,gsm,ashleyEngine);
_uiStage = new UiStage();
_entityManager = new EntityManager(ashleyEngine, _batch, _gameCamera, inputhandler, _uiStage, gsm, entityFactory);
InputMultiplexer multi = new InputMultiplexer();
multi.addProcessor(_uiStage);
multi.addProcessor(inputhandler);
Gdx.input.setInputProcessor(multi);
}
示例3: add
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
public static void add(Engine engine) {
// build cave
Maker maker = new Maker().setMesh("assets/models/cave_old.obj")
.setShader("assets/shaders/cc/depth.vert.glsl", "assets/shaders/cc/depth.frag.glsl")
.setTexture(0, "assets/textures/RockPerforated0029_1_seamless_S.png")
.setTexture(4, "assets/textures/fog-gradient-03.png")
.setTextureScale(12f);
engine.addEntity(maker.build());
// build seafloor
maker.setMesh("assets/models/seafloor.obj")
.setShader("assets/shaders/cc/caustic.vert.glsl", "assets/shaders/cc/caustic.frag.glsl");
engine.addEntity(maker.build());
addMainCamera(engine);
addAuxiliaryQuantumLightConvolutionAcceleratorBuffer();
addFishflock(engine, 7, 7, 7, 0.4f);
addSkybox(engine);
//addFishflock(engine, 3, 5, 3, 0.5f);
}
示例4: intervalSystem
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Test
public void intervalSystem () {
Engine engine = new Engine();
IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(IntervalComponentSpy.class).get());
ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);
engine.addSystem(intervalSystemSpy);
for (int i = 0; i < 10; ++i) {
Entity entity = new Entity();
entity.add(new IntervalComponentSpy());
engine.addEntity(entity);
}
for (int i = 1; i <= 10; ++i) {
engine.update(deltaTime);
for (int j = 0; j < entities.size(); ++j) {
assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
}
}
}
示例5: init
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
public static void init(Engine engine)
{
ecsEngine = engine;
PhysicsSystem physicsSystem = engine.getSystem(PhysicsSystem.class);
OverlapSceneLoader.registerPlugin("levelConfig", new SceneConfigPlugin());
OverlapSceneLoader.registerPlugin("cctv", new CCTvPlugin());
OverlapSceneLoader.registerPlugin("grunt", new GruntPlugin(physicsSystem));
OverlapSceneLoader.registerPlugin("player", new PlayerPlugin(
engine.getSystem(CameraSystem.class)
));
OverlapSceneLoader.registerPlugin("endOfLevel", new EndOfLevelPlugin(physicsSystem));
OverlapSceneLoader.registerPlugin("door", new DoorPlugin());
OverlapSceneLoader.registerPlugin("button", new ButtonPlugin(
physicsSystem, engine.getSystem(DoorSystem.class)));
OverlapSceneLoader.registerPlugin("box", new BoxPlugin(physicsSystem));
}
示例6: create
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void create()
{
GameSettingsComponent settings = new GameSettingsComponent();
settings.setGuiWidth(width);
settings.setGuiHeight(height);
settings.setWorldToScreen(32f);
settings.setGravity(new Vector2(0, -9.81f));
settings.setTimeStep(1 / 300f);
settings.setPaused(false);
GameWorld gameWorld = new GameWorld(settings);
engine = new Engine();
engine.addEntity(gameWorld);
engine.addSystem(new AccumulatorSystem());
engine.addSystem(new MovementSystem());
engine.addSystem(new JumpingSystem());
setScreen(new GameScreen(engine, gameWorld.getId()));
}
示例7: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
updateEntities(engine);
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("fonts/font.fnt"));
font.setUseIntegerPositions(false);
debugRenderer = new ShapeRenderer();
particleRenderer = new ShapeRenderer();
camera = new OrthographicCamera();
camera.setToOrtho(false, 1, 1);
fontCamera = new OrthographicCamera();
fontCamera.setToOrtho(false, Global.FONT_SCALE, Global.FONT_SCALE);
drawableText = new ArrayList<TextObject>();
}
示例8: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
this.engine = engine;
entities = engine.getEntitiesFor(Family.all(PlainPosition.class).get());
// engine.addEntityListener(new EntityListener() {
//
// @Override
// public void entityRemoved(Entity entity) {
// engine.remove(entity.getIndex());
// }
//
// @Override
// public void entityAdded(Entity entity) {
// entities.put(entity.getIndex(), entity);
// }
// });
for (int i = 0; ENTITY_COUNT > i; i++)
createEntity();
}
示例9: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
for (int i = 0; permutations.length > i; i++) {
Array<Class<? extends Component>> components = new Array<Class<? extends Component>>();
for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) {
components.add(types.get((int)(rng.nextFloat() * types.size)));
}
permutations[i] = components;
}
this.engine = engine;
entities = engine.getEntitiesFor(Family.all().get());
for (int i = 0; ENTITY_COUNT > i; i++)
createEntity();
}
示例10: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
this.engine = (PooledEngine) engine;
entities = engine.getEntitiesFor(Family.all(PlainPosition.class).get());
// engine.addEntityListener(new EntityListener() {
//
// @Override
// public void entityRemoved(Entity entity) {
// entities.remove(entity.getIndex());
// }
//
// @Override
// public void entityAdded(Entity entity) {
// entities.put(entity.getIndex(), entity);
// }
// });
for (int i = 0; ENTITY_COUNT > i; i++)
createEntity();
}
示例11: intervalSystem
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Test
public void intervalSystem() {
Engine engine = new Engine();
IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.getFor(IntervalComponentSpy.class));
ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);
engine.addSystem(intervalSystemSpy);
for (int i = 0; i < 10; ++i) {
Entity entity = new Entity();
entity.add(new IntervalComponentSpy());
engine.addEntity(entity);
}
for (int i = 1; i <= 10; ++i) {
engine.update(deltaTime);
for (int j = 0; j < entities.size(); ++j) {
assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
}
}
}
示例12: create
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void create() {
Gdx.input.setInputProcessor(inputProcessor);
physicsWorld = new World(new Vector2(0, -30), true);
entityEngine = new Engine();
entityEngine.addEntity(new CharacterEntity(physicsWorld));
entityEngine.addSystem(new PhysicsSystem(physicsWorld));
entityEngine.addSystem(new InputSystem(inputProcessor));
SceneRenderer sceneRenderer = new SceneRenderer(physicsWorld);
renderer = new PixelatedRenderer(sceneRenderer);
Level level = Level.fromMapPath("levels/level0.tmx");
level.populatePhysicsWorld(physicsWorld);
}
示例13: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
super.addedToEngine(engine);
this.camera = context.get(Camera.class);
this.physics = context.get(World.class);
if (Settings.DRAGGABLE_BOX2D_BODIES) {
jointDef = new MouseJointDef();
jointDef.bodyA = context.get(LBBuilders.class).getBodyBuilder().build();
jointDef.collideConnected = true;
jointDef.maxForce = Settings.DRAGGABLE_BOX2D_MAX_FORCE;
} else {
Log.error(tag, "A reference not set up a draggableRefBody");
}
}
示例14: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
super.addedToEngine(engine);
syncedEntities = engine.getEntitiesFor(Family.all(PlayerClass.class).get());
engine.addEntityListener(Family.all(NetworkAddComponent.class).get(), this);
player = engine.getEntitiesFor(Family.all(NetworkSyncComponent.class, PlayerClass.class, IdComponent.class).get());
}
示例15: addedToEngine
import com.badlogic.ashley.core.Engine; //导入依赖的package包/类
@Override
public void addedToEngine(Engine engine) {
super.addedToEngine(engine);
damageSystem.getDamageListeners().add(this);
players = engine.getEntitiesFor(Family.all(PlayerClass.class, IdComponent.class).get());
}