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


Java Renderable类代码示例

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


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

示例1: ActionModel

import com.b3dgs.lionengine.graphic.Renderable; //导入依赖的package包/类
/**
 * Create move action.
 * 
 * @param services The services reference.
 * @param setup The setup reference.
 */
public ActionModel(Services services, Setup setup)
{
    super();

    cursor = services.get(Cursor.class);
    selector = services.get(Selector.class);
    text = services.get(Text.class);

    addFeature(new LayerableModel(Constant.LAYER_SELECTION, Constant.LAYER_MENUS_RENDER));

    final SpriteAnimated background = Drawable.loadSpriteAnimated(Medias.create("action_background.png"), 2, 1);
    background.load();
    background.prepare();

    actionable = addFeatureAndGet(new ActionableModel(services, setup));
    actionable.setClickAction(Mouse.LEFT);
    actionable.setAction(new Action()
    {
        @Override
        public void execute()
        {
            cursor.setSurfaceId(1);
            cursor.setRenderingOffset(CURSOR_OFFSET, CURSOR_OFFSET);
            selector.setEnabled(false);
            state.set(assignable);
            ActionModel.this.action();
        }
    });
    state = new AtomicReference<Updatable>(actionable);

    assignable = addFeatureAndGet(new AssignableModel(services));
    assignable.setClickAssign(Mouse.LEFT);
    assignable.setAssign(new Assign()
    {
        @Override
        public void assign()
        {
            ActionModel.this.assign();
            cursor.setSurfaceId(0);
            cursor.setRenderingOffset(0, 0);
            selector.setEnabled(true);
            state.set(actionable);
        }
    });

    final SpriteTiled surface = Drawable.loadSpriteTiled(setup.getSurface(), 27, 19);
    surface.setLocation(actionable.getButton().getX(), actionable.getButton().getY());
    background.setLocation(actionable.getButton().getX() - 2, actionable.getButton().getY() - 2);

    addFeature(new RefreshableModel(new Updatable()
    {
        @Override
        public void update(double extrp)
        {
            if (actionable.isOver())
            {
                text.setText(actionable.getDescription());
            }
            state.get().update(extrp);
            ActionModel.this.update(extrp);
        }
    }));

    addFeature(new DisplayableModel(new Renderable()
    {
        @Override
        public void render(Graphic g)
        {
            background.render(g);
            surface.render(g);
            ActionModel.this.render(g);
        }
    }));
}
 
开发者ID:b3dgs,项目名称:warcraft-remake,代码行数:81,代码来源:ActionModel.java


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