本文整理汇总了Java中com.b3dgs.lionengine.game.Services类的典型用法代码示例。如果您正苦于以下问题:Java Services类的具体用法?Java Services怎么用?Java Services使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Services类属于com.b3dgs.lionengine.game包,在下文中一共展示了Services类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Entity
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create an entity.
*
* @param services The services reference.
* @param setup The setup used.
* @throws LionEngineException If error.
*/
public Entity(Services services, SetupSurfaceRastered setup)
{
super();
final FramesConfig frames = FramesConfig.imports(setup);
surface = Drawable.loadSpriteAnimated(setup.getSurface(), frames.getHorizontal(), frames.getVertical());
tileCollidable = addFeatureAndGet(new TileCollidableModel(services, setup));
body.setMass(2.0);
body.setGravityMax(7.0);
body.setDesiredFps(60);
body.setVectors(movement, jump);
viewer = services.get(Viewer.class);
StateAnimationBased.Util.loadStates(EntityState.values(), stateFactory, this, setup);
stateHandler.addInput(getInput());
stateHandler.changeState(EntityState.IDLE);
}
示例2: Mario
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Constructor.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public Mario(Services services, Setup setup)
{
super(services, setup);
addFeature(new LayerableModel(1));
addFeature(new TransformableModel());
addFeature(new BodyModel());
addFeature(new CollidableModel(services, setup));
addFeature(new TileCollidableModel(services, setup));
final MarioModel model = new MarioModel(setup);
addFeature(new MarioController(services, model));
addFeature(new MarioUpdater(services, model));
addFeature(new MarioRenderer(services, model));
}
示例3: ShipModel
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create a ship.
*
* @param services The services reference.
* @param setup The setup reference.
*/
ShipModel(Services services, Setup setup)
{
super();
factory = services.get(Factory.class);
handler = services.get(Handler.class);
final SizeConfig config = SizeConfig.imports(setup);
surface = Drawable.loadSpriteTiled(setup.getSurface(), config.getWidth(), config.getHeight());
surface.setOrigin(Origin.MIDDLE);
hit = Drawable.loadSpriteAnimated(Medias.create(Constant.FOLDER_EFFECT, "Hit.png"), 1, 1);
hit.load();
hit.prepare();
hit.setOrigin(Origin.CENTER_BOTTOM);
hit.setFrameOffsets(1, OFFSET_Y);
shield.fill();
armor.fill();
energy.fill();
front = createWeapon(Weapon.PULSE_CANNON);
rear = createWeapon(Weapon.SONIC_WAVE);
}
示例4: generate
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Generate a map.
*
* @param services The services reference.
* @param theme The theme name.
* @return The generated map.
*/
public static MapTile generate(Services services, String theme)
{
final MapTile map = services.create(MapTileGame.class);
map.addFeature(new LayerableModel(Constant.LAYER_MAP));
map.loadSheets(Medias.create(Constant.FOLDER_TILE, theme, TileSheetsConfig.FILENAME));
final java.util.Map<TileRef, Media> entities = getEntities(theme);
final TileSetListener listener = createListener(entities, map, services);
map.addListener(listener);
final List<MapTile> maps = getMaps(theme, MAX_LEVELS);
final Collection<MapTile> levels = new ArrayList<MapTile>();
for (int i = 0; i < MAX_LEVELS; i++)
{
final MapTile current = maps.get(UtilRandom.getRandomInteger(maps.size() - 1));
levels.add(current);
}
map.append(levels, 0, 1, 0, MAX_LEVEL_INTERVAL_HEIGHT_IN_TILE);
map.removeListener(listener);
entities.clear();
return map;
}
示例5: getMaps
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Get a list of maps.
*
* @param theme The theme name.
* @param count The file level count.
* @return List of maps.
*/
private static List<MapTile> getMaps(String theme, int count)
{
final List<MapTile> maps = new ArrayList<MapTile>();
for (int i = 0; i <= count; i++)
{
final Media level = Medias.create(Constant.FOLDER_LEVELS, theme, i + ".map");
final Services services = new Services();
final MapTile map = services.create(MapTileGame.class);
final MapTilePersister persister = map.addFeatureAndGet(new MapTilePersisterModel(services));
try
{
final FileReading reading = new FileReading(level);
persister.load(reading);
reading.close();
}
catch (final IOException exception)
{
Verbose.exception(exception);
}
maps.add(map);
}
return maps;
}
示例6: Effect
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create an effect.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public Effect(Services services, Setup setup)
{
super(services, setup);
viewer = services.get(Viewer.class);
addFeature(new Recycler());
addFeature(new LayerableModel(Constant.LAYER_EFFECT));
transformable = addFeatureAndGet(new TransformableModel(setup));
final EffectModel model = addFeatureAndGet(new EffectModel(setup));
addFeature(new EffectUpdater(services, model));
addFeature(new EffectRenderer(model));
anim = AnimationConfig.imports(setup).getAnimation("start");
surface = model.getSurface();
}
示例7: ChangeWeapon
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create power up action.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public ChangeWeapon(Services services, Setup setup)
{
super();
factory = services.get(Factory.class);
if (setup.hasNode(NODE_WEAPON_FRONT))
{
media = Medias.create(Constant.FOLDER_WEAPON,
Constant.FOLDER_FRONT,
setup.getText(NODE_WEAPON_FRONT) + Factory.FILE_DATA_DOT_EXTENSION);
}
else if (setup.hasNode(NODE_WEAPON_REAR))
{
media = Medias.create(Constant.FOLDER_WEAPON,
Constant.FOLDER_REAR,
setup.getText(NODE_WEAPON_REAR) + Factory.FILE_DATA_DOT_EXTENSION);
}
else
{
media = null;
}
}
示例8: EntityStats
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create icon provider.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public EntityStats(Services services, Setup setup)
{
super();
text = services.get(Text.class);
name = setup.getString("name");
final Media media = setup.getIconFile();
if (media != null)
{
icon = Drawable.loadImage(media);
icon.load();
icon.setLocation(Constant.ENTITY_INFO_X + ENTITY_INFO_MARGIN, Constant.ENTITY_INFO_Y + ENTITY_INFO_MARGIN);
}
else
{
icon = null;
}
life.fill();
barLife.setColorForeground(COLOR_LIFE);
barLife.setLocation((int) (icon.getX() + BAR_LIFE_X), (int) (icon.getY() + BAR_LIFE_Y));
}
示例9: Stop
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create move action.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public Stop(Services services, Setup setup)
{
super(services, setup);
actionable.setAction(new Action()
{
@Override
public void execute()
{
final List<Selectable> selection = selector.getSelection();
final int n = selection.size();
for (int i = 0; i < n; i++)
{
selection.get(i).getFeature(Pathfindable.class).stopMoves();
}
}
});
}
示例10: MarioUpdater
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create updater.
*
* @param services The services reference.
* @param model The model reference.
*/
public MarioUpdater(Services services, MarioModel model)
{
context = services.get(Context.class);
movement = model.getMovement();
jump = model.getJump();
}
示例11: MarioRenderer
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Constructor.
*
* @param services The services reference.
* @param model The model reference.
*/
public MarioRenderer(Services services, MarioModel model)
{
super();
viewer = services.get(Viewer.class);
surface = model.getSurface();
}
示例12: MarioController
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create updater.
*
* @param services The services reference.
* @param model The model reference.
*/
public MarioController(Services services, MarioModel model)
{
movement = model.getMovement();
jump = model.getJump();
keyboard = services.get(Keyboard.class);
}
示例13: World
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create the world.
*
* @param context The context reference.
* @param services The services reference.
*/
public World(Context context, Services services)
{
super(context, services);
final double scaleH = config.getSource().getWidth() / (double) Constant.NATIVE.getWidth();
final double scaleV = config.getSource().getHeight() / (double) Constant.NATIVE.getHeight();
factoryLandscape = new FactoryLandscape(source, scaleH, scaleV, false);
handler.addComponent(new ComponentCollision());
handler.add(map);
}
示例14: ShipControllerAndroid
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create an Android ship controller.
*
* @param services The services reference.
* @param setup The setup reference.
*/
public ShipControllerAndroid(Services services, Setup setup)
{
super();
mouse = services.get(Mouse.class);
camera = services.get(Camera.class);
}
示例15: EntityRenderer
import com.b3dgs.lionengine.game.Services; //导入依赖的package包/类
/**
* Create an entity renderer.
*
* @param services The services reference.
*/
EntityRenderer(Services services)
{
super();
viewer = services.get(Viewer.class);
}