当前位置: 首页>>代码示例>>Java>>正文


Java Collidable类代码示例

本文整理汇总了Java中com.b3dgs.lionengine.game.feature.collidable.Collidable的典型用法代码示例。如果您正苦于以下问题:Java Collidable类的具体用法?Java Collidable怎么用?Java Collidable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Collidable类属于com.b3dgs.lionengine.game.feature.collidable包,在下文中一共展示了Collidable类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ignoreProjectileCollision

import com.b3dgs.lionengine.game.feature.collidable.Collidable; //导入依赖的package包/类
/**
 * Ignore weapon projectiles collision.
 * 
 * @param launcher The launcher to ignore.
 */
private void ignoreProjectileCollision(Launcher launcher)
{
    launcher.addListener(new LauncherListener()
    {
        @Override
        public void notifyFired()
        {
            energy.decrease(ENERGY);
        }
    });
    launcher.addListener(new LaunchableListener()
    {
        @Override
        public void notifyFired(Launchable launchable)
        {
            launchable.getFeature(Collidable.class).setGroup(Constant.COLLISION_GROUP_PROJECTILES_SHIP);
        }
    });
}
 
开发者ID:b3dgs,项目名称:tyrian-remake,代码行数:25,代码来源:ShipModel.java

示例2: notifyCollided

import com.b3dgs.lionengine.game.feature.collidable.Collidable; //导入依赖的package包/类
@Override
public void notifyCollided(Collidable collidable)
{
    if (collidable.hasFeature(EntityModel.class))
    {
        final double dir = collidable.getFeature(EntityModel.class).getDirection().getDirectionVertical();
        if (dir < 0)
        {
            onHit(dir);
        }
    }
    if (collidable.hasFeature(Launchable.class))
    {
        if (getFeature(ShipRenderer.class).showHit(transformable))
        {
            onHurt(3);
        }
        collidable.getFeature(Identifiable.class).destroy();
    }
    if (collidable.hasFeature(Action.class))
    {
        collidable.getFeature(Action.class).action(model);
    }
}
 
开发者ID:b3dgs,项目名称:tyrian-remake,代码行数:25,代码来源:ShipUpdater.java

示例3: prepare

import com.b3dgs.lionengine.game.feature.collidable.Collidable; //导入依赖的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: notifyCollided

import com.b3dgs.lionengine.game.feature.collidable.Collidable; //导入依赖的package包/类
@Override
public void notifyCollided(Collidable collidable)
{
    Sfx.BULLET_HIT.play();
    spawnEffectHit();

    life.decrease(1);
    if (life.getCurrent() == 0)
    {
        spawnEffectExplode();
        getFeature(Identifiable.class).destroy();
    }

    collidable.getFeature(Identifiable.class).destroy();
}
 
开发者ID:b3dgs,项目名称:tyrian-remake,代码行数:16,代码来源:EntityUpdater.java

示例5: World

import com.b3dgs.lionengine.game.feature.collidable.Collidable; //导入依赖的package包/类
/**
 * Create the world.
 * 
 * @param context The context reference.
 * @param services The services reference.
 */
public World(Context context, Services services)
{
    super(context, services);

    final Resolution source = context.getConfig().getSource();
    camera.setView(VIEW_X, VIEW_Y, source.getWidth() - VIEW_X, source.getHeight() - VIEW_Y, source.getHeight());

    handler.addComponent(new ComponentCollision());

    map.addFeature(new MapTileViewerModel(services));
    map.addFeature(new MapTilePersisterModel(services));
    map.addFeature(new MapTileGroupModel());
    map.addFeature(new MapTilePathModel(services));
    handler.add(map);

    final Hud hud = factory.create(Medias.create("Hud.xml"));
    handler.add(hud);

    final Selector selector = services.get(Selector.class);
    selector.addFeature(new LayerableModel(Constant.LAYER_SELECTION, Constant.LAYER_SELECTION_RENDER));
    selector.setClickableArea(camera);
    selector.setSelectionColor(ColorRgba.GREEN);
    selector.setClickSelection(Mouse.LEFT);
    selector.getFeature(Collidable.class).addAccept(Constant.LAYER_ENTITY);

    text.setLocation(TEXT_X, TEXT_Y);
    text.setColor(TEXT_COLOR);

    services.add(Integer.valueOf(source.getRate()));
}
 
开发者ID:b3dgs,项目名称:warcraft-remake,代码行数:37,代码来源:World.java


注:本文中的com.b3dgs.lionengine.game.feature.collidable.Collidable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。