Example usage for com.badlogic.gdx.graphics Color GREEN

List of usage examples for com.badlogic.gdx.graphics Color GREEN

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Color GREEN.

Prototype

Color GREEN

To view the source code for com.badlogic.gdx.graphics Color GREEN.

Click Source Link

Usage

From source file:cb.pong.model.Pieces.java

public void render() {
    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(Color.GREEN);
    for (Point pos : getBlocks()) {
        shapeRenderer.rect(pos.getX() * 20, pos.getY() * 20, 18, 18);
    }/*from  www.  jav a 2  s .  co  m*/
    shapeRenderer.end();

}

From source file:CB_UI.GL_UI.Controls.SatBarChart.java

License:Open Source License

private void setSatStrength() {
    float minH = (Sprites.bar.getBottomHeight() / 2) + Sprites.bar.getTopHeight();

    float w = (this.getWidth() / 14);
    boolean small = Sprites.bar.getMinWidth() > w * 1.2f;
    if (small) {/*from  w  ww.  j a  v a2 s  .co m*/
        w = (this.getWidth() / 12);
    }

    // calc Colors
    Color red = Color.RED.cpy();
    Color grn = Color.GREEN.cpy();
    Color gry = Color.LIGHT_GRAY.cpy();

    if (drawWithAlpha) {
        red.a = 0.4f;
        grn.a = 0.4f;
        gry.a = 0.4f;
    }

    if (balken == null) {

        float iniHeight = small ? Sprites.barSmall.getTopHeight() : Sprites.bar.getTopHeight();

        w += 1;
        balken = new Image[14];
        balken[0] = new Image(new CB_RectF(0, 0, w, iniHeight), "", false);
        balken[1] = new Image(new CB_RectF(balken[0].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[2] = new Image(new CB_RectF(balken[1].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[3] = new Image(new CB_RectF(balken[2].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[4] = new Image(new CB_RectF(balken[3].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[5] = new Image(new CB_RectF(balken[4].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[6] = new Image(new CB_RectF(balken[5].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[7] = new Image(new CB_RectF(balken[6].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[8] = new Image(new CB_RectF(balken[7].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[9] = new Image(new CB_RectF(balken[8].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[10] = new Image(new CB_RectF(balken[9].getMaxX() - 1, 0, w, iniHeight), "", false);
        balken[11] = new Image(new CB_RectF(balken[10].getMaxX() - 1, 0, w, iniHeight), "", false);
        if (!small)
            balken[12] = new Image(new CB_RectF(balken[11].getMaxX() - 1, 0, w, iniHeight), "", false);
        if (!small)
            balken[13] = new Image(new CB_RectF(balken[12].getMaxX() - 1, 0, w, iniHeight), "", false);

        for (Image tmp : balken) {
            if (tmp != null) {
                tmp.setDrawable(small ? Sprites.barSmall_0 : Sprites.bar_0);
                this.addChild(tmp);
            }
        }
    }

    int count = 0;
    if (GPS.getSatList() != null) {
        for (int i = 0, n = GPS.getSatList().size(); i < n; i++) {
            GpsStrength tmp;
            try {
                tmp = GPS.getSatList().get(i);
            } catch (Exception e) {
                break;
            }

            try {
                // balken hhe festlegen
                if (balken[count] != null) {
                    float barHeight = Math.min((tmp.getStrength() * 3 / 100) * this.getHeight(),
                            this.getHeight());

                    if (barHeight < minH) {
                        barHeight = small ? Sprites.barSmall.getTopHeight() : Sprites.bar.getTopHeight();
                        balken[count].setDrawable(small ? Sprites.barSmall_0 : Sprites.bar_0);
                    } else {
                        balken[count].setDrawable(small ? Sprites.barSmall : Sprites.bar);
                    }

                    balken[count].setHeight(barHeight);

                    // // balken farbe festlegen
                    if (tmp.getFixed()) {
                        balken[count].setColor(grn);
                    } else {
                        balken[count].setColor(red);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            count++;
            if (count >= 13)
                break;
        }
    }

    // restliche balken ausschalten!
    if (count < 14) {
        for (int i = count; i <= 13; i++) {
            if (balken[i] != null)
                balken[i].setColor(gry);
        }
    }

    redraw = false;
    GL.that.renderOnce();

}

From source file:CB_UI.GL_UI.Views.MapView.java

License:Open Source License

public MapView(CB_RectF rec, MapMode Mode, String Name) {
    super(rec, Name);
    // statischen that nur setzen wenn die HauptMapView initialisiert wird
    if (Mode == MapMode.Normal) {
        that = this;
    } else {//from w  w  w .  jav a  2 s .co m
        this.setOnDoubleClickListener(new OnClickListener() {

            @Override
            public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) {
                // Center own position!
                setCenter(Locator.getCoordinate());
                return true;
            }
        });
    }

    this.Mode = Mode;

    Config.MapsforgeDayTheme.addChangedEventListener(themeChangedEventHandler);
    Config.MapsforgeNightTheme.addChangedEventListener(themeChangedEventHandler);

    registerSkinChangedEvent();
    setBackground(Sprites.ListBack);
    int maxNumTiles = 0;
    // calculate max Map Tile cache
    try {
        int aTile = 256 * 256;
        maxTilesPerScreen = (int) ((rec.getWidth() * rec.getHeight()) / aTile + 0.5);

        maxNumTiles = (int) (maxTilesPerScreen * 6);// 6 times as much as necessary

    } catch (Exception e) {
        maxNumTiles = 60;
    }

    maxNumTiles = Math.min(maxNumTiles, 60);
    maxNumTiles = Math.max(maxNumTiles, 20);

    mapTileLoader.setMaxNumTiles(maxNumTiles);

    mapScale = new MapScale(new CB_RectF(GL_UISizes.margin, GL_UISizes.margin, this.getHalfWidth(),
            GL_UISizes.ZoomBtn.getHalfWidth() / 4), "mapScale", this, Config.ImperialUnits.getValue());

    if (Mode == MapMode.Normal) {
        this.addChild(mapScale);
    } else {
        mapScale.setInvisible();
    }

    // initial Zoom Buttons
    zoomBtn = new ZoomButtons(GL_UISizes.ZoomBtn, this, "ZoomButtons");

    zoomBtn.setX(this.getWidth() - (zoomBtn.getWidth() + UI_Size_Base.that.getMargin()));

    zoomBtn.setOnClickListenerDown(new OnClickListener() {
        @Override
        public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) {
            // bei einer Zoom Animation in negativer Richtung muss der setDiffCameraZoom gesetzt werden!
            // zoomScale.setDiffCameraZoom(-1.9f, true);
            // zoomScale.setZoom(zoomBtn.getZoom());
            zoomScale.resetFadeOut();
            inputState = InputState.Idle;

            lastDynamicZoom = zoomBtn.getZoom();

            kineticZoom = new KineticZoom(camera.zoom, MapTileLoader.getMapTilePosFactor(zoomBtn.getZoom()),
                    System.currentTimeMillis(), System.currentTimeMillis() + ZoomTime);
            GL.that.addRenderView(MapView.this, GL.FRAME_RATE_ACTION);
            GL.that.renderOnce();
            calcPixelsPerMeter();
            return true;
        }
    });
    zoomBtn.setOnClickListenerUp(new OnClickListener() {
        @Override
        public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) {
            setZoomScale(zoomBtn.getZoom());
            zoomScale.resetFadeOut();
            inputState = InputState.Idle;

            lastDynamicZoom = zoomBtn.getZoom();

            kineticZoom = new KineticZoom(camera.zoom, MapTileLoader.getMapTilePosFactor(zoomBtn.getZoom()),
                    System.currentTimeMillis(), System.currentTimeMillis() + ZoomTime);
            GL.that.addRenderView(MapView.this, GL.FRAME_RATE_ACTION);
            GL.that.renderOnce();
            calcPixelsPerMeter();
            return true;
        }
    });

    if (Mode == MapMode.Compass) {
        zoomBtn.setInvisible();
    } else {
        this.addChild(zoomBtn);
        zoomBtn.setMinimumFadeValue(0.25f);
    }

    this.setOnClickListener(onClickListener);

    float InfoHeight = 0;
    if (Mode == MapMode.Normal) {
        info = (MapInfoPanel) this.addChild(new MapInfoPanel(GL_UISizes.Info, "InfoPanel", this));
        InfoHeight = info.getHeight();
    }

    CB_RectF ZoomScaleRec = new CB_RectF();
    ZoomScaleRec.setSize((float) (44.6666667 * GL_UISizes.DPI),
            this.getHeight() - InfoHeight - (GL_UISizes.margin * 4) - zoomBtn.getMaxY());
    ZoomScaleRec.setPos(new Vector2(GL_UISizes.margin, zoomBtn.getMaxY() + GL_UISizes.margin));

    zoomScale = new ZoomScale(ZoomScaleRec, "zoomScale", 2, 21, 12);
    if (Mode == MapMode.Normal)
        this.addChild(zoomScale);

    mapIntWidth = (int) rec.getWidth();
    mapIntHeight = (int) rec.getHeight();
    drawingWidth = mapIntWidth;
    drawingHeight = mapIntHeight;

    InitializeMap();

    // initial Zoom Scale
    // zoomScale = new GL_ZoomScale(6, 20, 13);

    mapCacheList = new MapViewCacheList(MapTileLoader.MAX_MAP_ZOOM);

    // from create

    String[] currentLayerNames = Config.CurrentMapLayer.getValue();
    if (ManagerBase.Manager != null) {
        if (mapTileLoader.getCurrentLayer() == null) {
            mapTileLoader.setCurrentLayer(
                    ManagerBase.Manager.getOrAddLayer(currentLayerNames, currentLayerNames[0], ""));
        }
    }

    String[] currentOverlayLayerName = new String[] { Config.CurrentMapOverlayLayer.getValue() };
    if (ManagerBase.Manager != null) {
        if (mapTileLoader.getCurrentOverlayLayer() == null && currentOverlayLayerName[0].length() > 0)
            mapTileLoader.setCurrentOverlayLayer(
                    ManagerBase.Manager.getOrAddLayer(currentOverlayLayerName, currentOverlayLayerName[0], ""));
    }

    iconFactor = Config.MapViewDPIFaktor.getValue();

    liveButton = new LiveButton();
    liveButton.setState(Config.LiveMapEnabeld.getDefaultValue());
    Config.DisableLiveMap.addChangedEventListener(new IChanged() {
        @Override
        public void isChanged() {
            requestLayout();
        }
    });

    togBtn = new MultiToggleButton(GL_UISizes.Toggle, "toggle");

    togBtn.addState("Free", new HSV_Color(Color.GRAY));
    togBtn.addState("GPS", new HSV_Color(Color.GREEN));
    togBtn.addState("WP", new HSV_Color(Color.MAGENTA));
    togBtn.addState("Lock", new HSV_Color(Color.RED));
    togBtn.addState("Car", new HSV_Color(Color.YELLOW));
    togBtn.setLastStateWithLongClick(true);

    MapState last = MapState.values()[Config.LastMapToggleBtnState.getValue()];
    togBtn.setState(last.ordinal());

    togBtn.setOnStateChangedListener(new OnStateChangeListener() {

        @Override
        public void onStateChange(GL_View_Base v, int State) {
            setMapState(MapState.values()[State]);
        }
    });
    togBtn.registerSkinChangedEvent();

    switch (Mode) {
    case Compass:
        setMapState(MapState.GPS);
        break;
    case Normal:
        setMapState(last);
        break;
    case Track:
        setMapState(MapState.FREE);
        break;
    }

    if (Mode == MapMode.Normal) {
        switch (Config.LastMapToggleBtnState.getValue()) {
        case 0:
            info.setCoordType(CoordType.Map);
            break;
        case 1:
            info.setCoordType(CoordType.GPS);
            break;
        case 2:
            info.setCoordType(CoordType.Cache);
            break;
        case 3:
            info.setCoordType(CoordType.GPS);
            break;
        case 4:
            info.setCoordType(CoordType.GPS);
            break;
        }
    }

    if (Mode == MapMode.Normal) {
        this.addChild(togBtn);
        if (Config.DisableLiveMap.getValue()) {
            liveButton.setState(false);
        }
        this.addChild(liveButton);
    }

    infoBubble = new InfoBubble(GL_UISizes.Bubble, "infoBubble");
    infoBubble.setInvisible();
    infoBubble.setOnClickListener(new OnClickListener() {
        @Override
        public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) {
            if (infoBubble.saveButtonClicked(x, y)) {
                wd = CancelWaitDialog.ShowWait(Translation.Get("ReloadCacheAPI"),
                        DownloadAnimation.GetINSTANCE(), new IcancelListener() {
                            @Override
                            public void isCanceld() {

                            }
                        }, new cancelRunnable() {

                            @Override
                            public void run() {
                                String GcCode = infoBubble.getCache().getGcCode();

                                SearchGC searchC = new SearchGC(GcCode);
                                searchC.number = 1;
                                searchC.available = false;

                                CB_List<Cache> apiCaches = new CB_List<Cache>();
                                ArrayList<LogEntry> apiLogs = new ArrayList<LogEntry>();
                                ArrayList<ImageEntry> apiImages = new ArrayList<ImageEntry>();

                                try {
                                    CB_UI.SearchForGeocaches.getInstance().SearchForGeocachesJSON(searchC,
                                            apiCaches, apiLogs, apiImages,
                                            infoBubble.getCache().getGPXFilename_ID(), this);
                                    Cache c = apiCaches.get(0);
                                    if (c.getGcCode() == GcCode) {
                                        c.setApiStatus(Cache.NOTLITE);
                                    }
                                    GroundspeakAPI.WriteCachesLogsImages_toDB(apiCaches, apiLogs, apiImages);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }

                                // Reload result from DB
                                synchronized (Database.Data.Query) {
                                    String sqlWhere = FilterInstances.getLastFilter()
                                            .getSqlWhere(Config.GcLogin.getValue());
                                    CacheListDAO cacheListDAO = new CacheListDAO();
                                    cacheListDAO.ReadCacheList(Database.Data.Query, sqlWhere, false,
                                            Config.ShowAllWaypoints.getValue());
                                }

                                CacheListChangedEventList.Call();
                                Cache selCache = Database.Data.Query.GetCacheByGcCode(GcCode);
                                GlobalCore.setSelectedCache(selCache);
                                infoBubble.setCache(selCache, null, true);
                                wd.close();
                            }

                            @Override
                            public boolean cancel() {
                                // TODO handle cancel
                                return false;
                            }
                        });
            } else {
                if (infoBubble.getWaypoint() == null) {
                    // Wenn ein Cache einen Final waypoint hat dann soll gleich dieser aktiviert werden
                    Waypoint waypoint = infoBubble.getCache().GetFinalWaypoint();
                    // wenn ein Cache keine Final hat, aber einen StartWaypointm, dann wird dieser gleich selektiert
                    if (waypoint == null)
                        waypoint = infoBubble.getCache().GetStartWaypoint();
                    GlobalCore.setSelectedWaypoint(infoBubble.getCache(), waypoint);
                } else {
                    GlobalCore.setSelectedWaypoint(infoBubble.getCache(), infoBubble.getWaypoint());
                }
            }

            infoBubble.setInvisible();
            return true;
        }
    });
    if (Mode == MapMode.Normal)
        this.addChild(infoBubble);

    resize(rec.getWidth(), rec.getHeight());

    try {
        center = new CoordinateGPS(Config.MapInitLatitude.getValue(), Config.MapInitLongitude.getValue());
    } catch (Exception e) {
        e.printStackTrace();
    }

    // Info aktualisieren
    if (Mode == MapMode.Normal)
        info.setCoord(center);
    aktZoom = Config.lastZoomLevel.getValue();
    zoomBtn.setZoom(aktZoom);
    calcPixelsPerMeter();
    mapScale.zoomChanged();

    if ((center.getLatitude() == -1000) && (center.getLongitude() == -1000)) {
        // not initialized
        center = new CoordinateGPS(48, 12);
    }

    // Initial SettingsChanged Events
    MapView.that.SetNightMode(Config.nightMode.getValue());
    Config.nightMode.addChangedEventListener(new IChanged() {
        @Override
        public void isChanged() {
            MapView.this.SetNightMode(Config.nightMode.getValue());
        }
    });

    MapView.that.SetNorthOriented(Config.MapNorthOriented.getValue());
    Config.MapNorthOriented.addChangedEventListener(new IChanged() {

        @Override
        public void isChanged() {
            MapView.this.SetNorthOriented(Config.MapNorthOriented.getValue());
            MapView.this.PositionChanged();
        }
    });

}

From source file:CB_UI.RouteOverlay.java

License:Open Source License

private static void initialColorField() {
    ColorField[0] = Color.RED;// w w  w. j a  va  2 s .  c  o  m
    ColorField[1] = Color.YELLOW;
    ColorField[2] = Color.BLACK;
    ColorField[3] = Color.LIGHT_GRAY;
    ColorField[4] = Color.GREEN;
    ColorField[5] = Color.BLUE;
    ColorField[6] = Color.CYAN;
    ColorField[7] = Color.GRAY;
    ColorField[8] = Color.MAGENTA;
    ColorField[9] = Color.ORANGE;
    ColorField[10] = Color.DARK_GRAY;
    ColorField[11] = Color.PINK;
    ColorField[12] = Color.WHITE;
}

From source file:com.badlogic.gdx.tests.dragome.examples.GearsDemo.java

@Override
public void create() {

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .2f, .2f, .2f, 2f));
    //      environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0f, -0.5f, -0.5f));

    sl = new PointLight().setPosition(-5, 10, -6).setColor(1, 1, 1, 1).setIntensity(150);

    //      sl2 = new PointLight().setPosition(0, 7, 5).setColor(0.3f, 0.8f, 0.3f, 1)
    //         .setIntensity(20);
    ///*from w  w  w.j  av  a2s .  co  m*/
    //      sl3 = new PointLight().setPosition(0, 9, 6).setColor(0.3f, 0.3f, 0.8f, 1)
    //         .setIntensity(20);

    environment.add(sl);
    //      environment.add(sl2);
    //      environment.add(sl3);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(-10, 3, 10f);
    cam.lookAt(-3, 0, 0);
    cam.near = 1f;
    cam.far = 100f;
    cam.update();

    cameraController = new CameraInputController(cam);
    cameraController.autoUpdate = false;
    cameraController.forwardTarget = false;
    cameraController.translateTarget = false;

    Gdx.input.setInputProcessor(new InputMultiplexer(cameraController));

    time = TimeUtils.millis();

    viewport = new ScreenViewport(cam);
    guiViewport = new ScreenViewport();

    DefaultShaderProvider defaultShaderProvider = new DefaultShaderProvider();
    modelBatch = new ModelBatch(defaultShaderProvider);

    ModelBuilder modelBuilder = new ModelBuilder();
    model1 = gear(modelBuilder, 1.0f, 4.0f, 1.0f, 20, 0.7f, Color.RED);
    gear1 = new ModelInstance(model1);

    model2 = gear(modelBuilder, 0.5f, 2.0f, 2.0f, 10, 0.7f, Color.GREEN);
    gear2 = new ModelInstance(model2);

    model3 = gear(modelBuilder, 1.3f, 2.0f, 1.5f, 10, 0.7f, Color.BLUE);
    gear3 = new ModelInstance(model3);

    font = new BitmapFont();

    batch = new SpriteBatch();

    lightModel = modelBuilder.createSphere(1, 1, 1, 10, 10,
            new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position);
    lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable());
}

From source file:com.badlogic.gdx.tests.ViewportTest3.java

License:Apache License

public void create() {
    modelBatch = new ModelBatch();
    modelBuilder = new ModelBuilder();

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f));
    shadowLight = new DirectionalLight();
    shadowLight.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f);
    environment.add(shadowLight);//  www. j  ava2  s .c o  m

    modelBatch = new ModelBatch();

    camera = new PerspectiveCamera();
    camera.fieldOfView = 67;
    camera.near = 0.1f;
    camera.far = 300f;
    camera.position.set(0, 0, 100);
    camera.lookAt(0, 0, 0);

    viewports = ViewportTest1.getViewports(camera);
    viewport = viewports.first();

    names = ViewportTest1.getViewportNames();
    name = names.first();

    ModelBuilder modelBuilder = new ModelBuilder();
    Model boxModel = modelBuilder.createBox(50f, 50f, 50f,
            new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
    boxInstance = new ModelInstance(boxModel);
    boxInstance.transform.rotate(1, 0, 0, 30);
    boxInstance.transform.rotate(0, 1, 0, 30);

    Gdx.input.setInputProcessor(new InputAdapter() {
        public boolean keyDown(int keycode) {
            if (keycode == Input.Keys.SPACE) {
                int index = (viewports.indexOf(viewport, true) + 1) % viewports.size;
                name = names.get(index);
                viewport = viewports.get(index);
                resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            }
            return false;
        }
    });
}

From source file:com.barconr.games.marblegame.Maze3Drenderer.java

License:Apache License

private void addBox(Vector3 position) {
    addBox(position, CUBE_SIZE + 0.1f, CUBE_SIZE + 0.1f, CUBE_SIZE + 0.1f, Color.GREEN);

}

From source file:com.bladecoder.engine.util.Utils3D.java

License:Apache License

private static void createAxes() {
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();//from w ww.j a v a  2  s. co m
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked,
            new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 10, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 10, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 10);
    axesModel = modelBuilder.end();
    axesInstance = new ModelInstance(axesModel);
}

From source file:com.bladecoder.engineeditor.scneditor.ScnWidget.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    validate();// w  w w  .  j  a  va  2  s.c  om

    Color tmp = batch.getColor();
    batch.setColor(Color.WHITE);

    if (scn != null && !loading && !loadingError) {
        // BACKGROUND
        batch.disableBlending();
        tile.draw(batch, getX(), getY(), getWidth(), getHeight());
        batch.enableBlending();

        Vector3 v = new Vector3(getX(), getY(), 0);
        v = v.prj(batch.getTransformMatrix());

        batch.end();

        HdpiUtils.glViewport((int) v.x, (int) v.y, (int) getWidth(), (int) (getHeight()));

        getStage().calculateScissors(bounds, scissors);

        if (ScissorStack.pushScissors(scissors)) {
            // WORLD CAMERA
            sceneBatch.setProjectionMatrix(camera.combined);
            sceneBatch.begin();

            Array<AtlasRegion> scnBackground = scn.getBackground();

            if (scnBackground != null) {
                sceneBatch.disableBlending();

                float x = 0;

                for (AtlasRegion tile : scnBackground) {
                    sceneBatch.draw(tile, x, 0f);
                    x += tile.getRegionWidth();
                }

                sceneBatch.enableBlending();
            }

            // draw layers from bottom to top
            List<SceneLayer> layers = scn.getLayers();
            for (int i = layers.size() - 1; i >= 0; i--) {
                SceneLayer layer = layers.get(i);

                if (!layer.isVisible())
                    continue;

                List<InteractiveActor> actors = layer.getActors();

                for (InteractiveActor a : actors) {
                    if (a instanceof SpriteActor) {
                        boolean visibility = a.isVisible();
                        a.setVisible(true);
                        ((SpriteActor) a).draw(sceneBatch);
                        a.setVisible(visibility);
                    }
                }
            }

            sceneBatch.end();
            ScissorStack.popScissors();
        }

        drawer.drawBGBounds();

        if (showWalkZone && scn.getPolygonalNavGraph() != null) {
            drawer.drawBBoxWalkZone(scn, false);

            drawer.drawPolygonVertices(scn.getPolygonalNavGraph().getWalkZone(), Color.GREEN);
        }

        drawer.drawBBoxActors(scn);

        if (selectedActor != null) {
            drawer.drawSelectedActor(selectedActor);
        }

        getStage().getViewport().apply();

        // SCREEN CAMERA
        batch.begin();

        drawFakeDepthMarkers((SpriteBatch) batch);

        if (!inScene) {
            faRenderer.draw((SpriteBatch) batch);
        }

        // DRAW COORDS
        Vector2 coords = new Vector2(Gdx.input.getX(), Gdx.input.getY());
        screenToWorldCoords(coords);
        String str = MessageFormat.format("({0}, {1})", (int) coords.x, (int) coords.y);

        textLayout.setText(defaultFont, str);

        RectangleRenderer.draw((SpriteBatch) batch, 0f, getY() + getHeight() - textLayout.height - 15,
                textLayout.width + 10, textLayout.height + 10, BLACK_TRANSPARENT);
        defaultFont.draw(batch, textLayout, 5, getHeight() + getY() - 10);

        batch.setColor(tmp);

    } else {
        background.draw(batch, getX(), getY(), getWidth(), getHeight());

        String s;

        if (loading) {
            s = "LOADING...";

            try {
                if (!EngineAssetManager.getInstance().isLoading()) {
                    loading = false;

                    scn.retrieveAssets();

                    drawer.setCamera(camera);

                    invalidate();
                }
            } catch (Exception e) {
                Message.showMsg(getStage(), "Could not load assets for scene", 4);
                e.printStackTrace();
                loadingError = true;
                loading = false;
            }

        } else if (loadingError) {
            s = "ERROR IN SCENE DATA. CANNOT DISPLAY SCENE";
        } else if (Ctx.project.getProjectDir() == null) {
            s = "CREATE OR LOAD A PROJECT";
        } else {
            s = "THERE ARE NO SCENES IN THIS CHAPTER YET";
        }

        textLayout.setText(bigFont, s);

        bigFont.draw(batch, textLayout, (getWidth() - textLayout.width) / 2,
                getHeight() / 2 + bigFont.getLineHeight() * 3);

    }

}

From source file:com.codefiddler.libgdx.tetris.domain.Tetrimino.java

License:Apache License

public static Tetrimino getS() {
    return new Tetrimino(S, Color.GREEN);
}