Example #1
0
  /**
   * Load a new mouse cursor graphic
   *
   * @param Graphic The image you want to use for the cursor.
   * @param Scale Change the size of the cursor.
   * @param XOffset The number of pixels between the mouse's screen position and the graphic's top
   *     left corner.
   * @param YOffset The number of pixels between the mouse's screen position and the graphic's top
   *     left corner.
   */
  public void load(String Graphic, float Scale, int XOffset, int YOffset) {
    if (_cursor != null) _cursorContainer.remove(_cursor);

    if (Graphic == null) Graphic = ImgDefaultCursor;
    _cursor = new FlxSprite(screenX, screenY, Graphic);
    _cursor.offset.x = XOffset;
    _cursor.offset.y = YOffset;
    _cursor.scale.x = Scale;
    _cursor.scale.y = Scale;
    _cursor.ignoreDrawDebug = true;
    _cursor.cameras = new Array<FlxCamera>();
    _cursor.cameras.addAll(
        new FlxCamera[] {new FlxCamera(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight())});

    _cursorContainer.add(_cursor);
  }
Example #2
0
 /**
  * Unload the current cursor graphic. If the current cursor is visible, then the default system
  * cursor is loaded up to replace the old one.
  */
 public void unload() {
   if (_cursor != null) {
     if (_cursorContainer.visible) load();
     else {
       _cursorContainer.remove(_cursor);
       _cursor = null;
     }
   }
 }
  @Override
  public void create() {
    FlxG.setBgColor(Breath.bgcolor);

    frame_buffer = new FrameBuffer(Pixmap.Format.RGBA8888, FlxG.width, FlxG.height, true);

    title_text =
        new FlxText(4, 24, 290, "\"I Can Hold My Breath Forever\"\nUse arrow keys to move.");
    title_text.setFormat(GardeniaFont, 8, 0xffffffff);

    PlayState.world_darkness = new FlxSprite(0, 0);
    world_darkness.scrollFactor.x = world_darkness.scrollFactor.y = 0;
    world_darkness.setPixels(
        new AtlasRegion(
            frame_buffer.getColorBufferTexture(),
            0,
            0,
            frame_buffer.getWidth(),
            frame_buffer.getHeight()));
    world_darkness.framePixels.flip(false, true);
    world_darkness.blend = "multiply";
    world_darkness.setAlpha(0);
    world_darkness.visible = false;

    frame_buffer_fill = new FlxSprite(0, 0);
    frame_buffer_fill.makeGraphic(FlxG.width, FlxG.height, darkness_color);
    frame_buffer_fill.scrollFactor.x = frame_buffer_fill.scrollFactor.y = 0;

    world = new World();

    background = new FlxSprite(0, 0, BackgroundImage);

    // Add restore point sprites
    notes = new FlxGroup();
    for (RestorePoint note : world.airbubble_restore_points.values()) {
      if (note.note) {
        notes.add(note);
      }
    }

    player = new Player(4 * World.TILE_SIZE, 9 * World.TILE_SIZE, world_darkness);

    darkness = new FlxSprite(0, 0);
    darkness.makeGraphic(FlxG.width, FlxG.height, 0xff000000);
    darkness.scrollFactor.x = darkness.scrollFactor.y = 0;
    darkness.setAlpha(0.0f);

    oxygen_timer_display = new FlxText(0, 0, FlxG.width, "10");
    oxygen_timer_display.setFormat(null, 160, 0xffffff, "center");
    oxygen_timer_display.setAlpha(0.0f);
    oxygen_timer_display.scrollFactor.x = oxygen_timer_display.scrollFactor.y = 0;

    story_overlay = new StoryOverlay(8, 2);

    world.walls_map.follow();
    // FlxG.followAdjust(0.5, 0.5);
    // FlxG.follow(player, 2.5);
    FlxG.camera.follow(player);

    // this.add(world.walls_map);
    // this.add(world.water_map);
    this.add(background);
    this.add(world.firefish_group);
    this.add(world.octopus);
    this.add(notes);
    this.add(player);
    this.add(world_darkness);
    this.add(darkness);
    this.add(oxygen_timer_display);
    this.add(story_overlay);
    this.add(title_text);
  }
Example #4
0
 /**
  * Either show an existing cursor or load a new one.
  *
  * @param Graphic The image you want to use for the cursor.
  * @param Scale Change the size of the cursor. Default = 1, or native size. 2 = 2x as big, 0.5 =
  *     half size, etc.
  * @param XOffset The number of pixels between the mouse's screen position and the graphic's top
  *     left corner.
  * @param YOffset The number of pixels between the mouse's screen position and the graphic's top
  *     left corner.
  */
 public void show(String Graphic, float Scale, int XOffset, int YOffset) {
   _cursorContainer.visible = true;
   if (Graphic != null) load(Graphic, Scale, XOffset, YOffset);
   else if (_cursor == null) load();
 }
Example #5
0
 /** Hides the mouse cursor */
 public void hide() {
   _cursorContainer.visible = false;
 }