本文整理汇总了Java中com.b3dgs.lionengine.game.feature.Transformable.teleport方法的典型用法代码示例。如果您正苦于以下问题:Java Transformable.teleport方法的具体用法?Java Transformable.teleport怎么用?Java Transformable.teleport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.b3dgs.lionengine.game.feature.Transformable
的用法示例。
在下文中一共展示了Transformable.teleport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawn
import com.b3dgs.lionengine.game.feature.Transformable; //导入方法依赖的package包/类
/**
* Spawn a random object from medias array.
*
* @param medias The medias array.
* @param layer The associated layer.
*/
private void spawn(List<Media> medias, int layer)
{
if (!medias.isEmpty())
{
final Media media = getRandomMedia(medias);
final Featurable featurable = factory.create(media);
featurable.getFeature(Layerable.class).setLayer(layer);
handler.add(featurable);
final Transformable transformable = featurable.getFeature(Transformable.class);
final double x = UtilRandom.getRandomInteger(camera.getWidth() - transformable.getWidth() * 2)
+ transformable.getWidth();
final double y = (int) camera.getY() + camera.getHeight() + transformable.getHeight();
transformable.teleport(x, y);
}
}
示例2: createListener
import com.b3dgs.lionengine.game.feature.Transformable; //导入方法依赖的package包/类
/**
* Create the map listener to add entities over tiles.
*
* @param entities The entities mapping.
* @param map The map reference.
* @param services The services reference.
* @return The created listener.
*/
private static TileSetListener createListener(final java.util.Map<TileRef, Media> entities,
final MapTile map,
Services services)
{
final Factory factory = services.get(Factory.class);
final Handler handler = services.get(Handler.class);
return new TileSetListener()
{
@Override
public void onTileSet(Tile tile)
{
final TileRef tileRef = new TileRef(tile);
if (entities.containsKey(tileRef))
{
final Media media = entities.get(tileRef);
final Entity entity = factory.create(media);
final Transformable transformable = entity.getFeature(Transformable.class);
final int x = (int) (tile.getX() + transformable.getWidth() / 2);
final int y = (int) (tile.getY() + map.getTileHeight() - transformable.getHeight() / 2);
transformable.teleport(x, y);
handler.add(entity);
}
}
};
}