當前位置: 首頁>>代碼示例>>Java>>正文


Java Transformable類代碼示例

本文整理匯總了Java中com.b3dgs.lionengine.game.feature.Transformable的典型用法代碼示例。如果您正苦於以下問題:Java Transformable類的具體用法?Java Transformable怎麽用?Java Transformable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Transformable類屬於com.b3dgs.lionengine.game.feature包,在下文中一共展示了Transformable類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
    }
}
 
開發者ID:b3dgs,項目名稱:tyrian-remake,代碼行數:22,代碼來源:World.java

示例2: createBase

import com.b3dgs.lionengine.game.feature.Transformable; //導入依賴的package包/類
/**
 * Create base world.
 * 
 * @param x The horizontal base.
 * @param y The vertical base.
 */
private void createBase(int x, int y)
{
    final Featurable peon = factory.create(Medias.create(Constant.FOLDER_ENTITY, Constant.FOLDER_ORC, "Peon.xml"));
    peon.getFeature(Pathfindable.class).setLocation(x, y);
    handler.add(peon);

    final Featurable grunt = factory.create(Medias.create(Constant.FOLDER_ENTITY,
                                                          Constant.FOLDER_ORC,
                                                          "Grunt.xml"));
    grunt.getFeature(Pathfindable.class).setLocation(x + 2, y + 1);
    handler.add(grunt);

    camera.teleport(grunt.getFeature(Transformable.class).getX()
                    - camera.getWidth() / 2,
                    grunt.getFeature(Transformable.class).getY() - camera.getHeight() / 2);
}
 
開發者ID:b3dgs,項目名稱:warcraft-remake,代碼行數:23,代碼來源:World.java

示例3: prepare

import com.b3dgs.lionengine.game.feature.Transformable; //導入依賴的package包/類
@Override
public void prepare(FeatureProvider provider)
{
    super.prepare(provider);

    weapon = factory.create(Medias.create(Constant.FOLDER_WEAPON, "pulser.xml")).getFeature(WeaponUpdater.class);

    final Transformable transformable = ship.getFeature(Transformable.class);
    target = new Localizable()
    {
        @Override
        public double getX()
        {
            return transformable.getX() + ship.getSpeed().getDirectionHorizontal();
        }

        @Override
        public double getY()
        {
            return transformable.getY() + ship.getSpeed().getDirectionVertical();
        }
    };

    weapon.getFeature(Launcher.class).addListener(new LaunchableListener()
    {
        @Override
        public void notifyFired(Launchable launchable)
        {
            launchable.getFeature(Collidable.class).setGroup(Constant.COLLISION_GROUP_PROJECTILES_ENTITIES);
        }
    });
}
 
開發者ID:b3dgs,項目名稱:tyrian-remake,代碼行數:33,代碼來源:Shooter.java

示例4: prepare

import com.b3dgs.lionengine.game.feature.Transformable; //導入依賴的package包/類
@Override
public void prepare(FeatureProvider provider)
{
    super.prepare(provider);

    player = services.get(ShipUpdater.class).getFeature(Transformable.class);
}
 
開發者ID:b3dgs,項目名稱:tyrian-remake,代碼行數:8,代碼來源:Ship.java

示例5: 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);
            }
        }
    };
}
 
開發者ID:b3dgs,項目名稱:tyrian-remake,代碼行數:35,代碼來源:Map.java

示例6: start

import com.b3dgs.lionengine.game.feature.Transformable; //導入依賴的package包/類
/**
 * Start the explode.
 * 
 * @param transformable The transformable reference.
 */
public void start(Transformable transformable)
{
    area.set(transformable.getX(), transformable.getY(), transformable.getWidth(), transformable.getHeight());
    count++;
}
 
開發者ID:b3dgs,項目名稱:tyrian-remake,代碼行數:11,代碼來源:Explode.java


注:本文中的com.b3dgs.lionengine.game.feature.Transformable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。