Package org.lwjgl.input

Examples of org.lwjgl.input.Cursor


      for(int l=0; l<cursorHeight; l++) {
        cursorImages.put(0xffffffff);
      }
    }
    cursorImages.flip();
    cursors[0] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
    // ----------------------------------

    // Create 3 piece animation
    // ==================================
    cursorImageCount = 3;
    cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
    cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
    for(int i=0; i<cursorImageCount; i++) {

      // make a colored square with a chocolate center
      int offColor = 0x00000000;
      int onColor = 0xffff0000;

      // change color according to cursor
      if(i == 1) {
        onColor = 0xff00ff00;
      } else if (i == 2) {
        onColor = 0xff0000ff;
      }

      // calculate size of center
      int centerSize  = (cursorWidth / 5) * (i + 1);
      int centerLeft  = cursorWidth / 2 - centerSize / 2;
      int centerRight = cursorWidth / 2 + centerSize / 2;

      // go!
      for(int j=0; j<cursorWidth; j++) {
        for(int l=0; l<cursorHeight; l++) {
          if(j >= centerLeft && j < centerRight && l >= centerLeft && l < centerRight) {
            cursorImages.put(offColor);
          } else {
            cursorImages.put(onColor);
          }
        }
      }
    }
    cursorDelays.put(2000).put(2000).put(2000);
    cursorDelays.flip();
    cursorImages.flip();

    cursors[1] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
    // ----------------------------------


    // Create a 20 piece animation
    // ==================================
    cursorImageCount = 20;
    cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
    cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
    cursorDelays.put(
                     new int[] {
                         100, 100, 100, 100, 100,
                        100, 100, 100, 100, 100,
                        100, 100, 100, 100, 100,
                        100, 100, 100, 100, 100
                     });

    float step = 0xffffffff / 20.0f;
    for(int i=0; i<cursorImageCount; i++) {
      for(int j=0; j<cursorWidth; j++) {
        for(int l=0; l<cursorHeight; l++) {
          cursorImages.put((int)step);
        }
      }
      step += step;
    }
    cursorImages.flip();
    cursorDelays.flip();
    cursors[2] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
    // ----------------------------------

    Mouse.setNativeCursor(cursors[0]);
  }
View Full Code Here


     * @see org.newdawn.slick.GameContainer#setMouseCursor(java.lang.String,
     *      int, int)
     */
      public void setMouseCursor(String ref, int hotSpotX, int hotSpotY) throws SlickException {
         try {
            Cursor cursor = CursorLoader.get().getCursor(ref, hotSpotX, hotSpotY);
            Mouse.setNativeCursor(cursor);
         } catch (Throwable e) {
            Log.error("Failed to load and apply cursor.", e);
      throw new SlickException("Failed to set mouse cursor", e);
         }
View Full Code Here

             ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
             g.drawImage(image.getFlippedCopy(false, true), 0, 0);
             g.flush();
             g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
            
             Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
             Mouse.setNativeCursor(cursor);
          } catch (Throwable e) {
             Log.error("Failed to load and apply cursor.", e);
        throw new SlickException("Failed to set mouse cursor", e);
          }
View Full Code Here

      /**
       * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)
       */
      public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY) throws SlickException {
         try {
            Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX, hotSpotY);
            Mouse.setNativeCursor(cursor);
         } catch (Throwable e) {
            Log.error("Failed to load and apply cursor.", e);
      throw new SlickException("Failed to set mouse cursor", e);
         }
View Full Code Here

  /**
   * @see org.newdawn.slick.GameContainer#setMouseCursor(java.lang.String, int, int)
   */
  public void setMouseCursor(String ref, int hotSpotX, int hotSpotY) throws SlickException {
    try {
      Cursor cursor = CursorLoader.get().getCursor(ref, hotSpotX, hotSpotY);
      Mouse.setNativeCursor(cursor);
    } catch (Throwable e) {
      Log.error("Failed to load and apply cursor.", e);
      throw new SlickException("Failed to set mouse cursor", e);
    }
View Full Code Here

  /**
   * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)
   */
  public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY) throws SlickException {
    try {
      Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX, hotSpotY);
      Mouse.setNativeCursor(cursor);
    } catch (Throwable e) {
      Log.error("Failed to load and apply cursor.", e);
      throw new SlickException("Failed to set mouse cursor", e);
    }
View Full Code Here

      ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
      g.drawImage(image.getFlippedCopy(false, true), 0, 0);
      g.flush();
      g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
     
      Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
      Mouse.setNativeCursor(cursor);
    } catch (Throwable e) {
      Log.error("Failed to load and apply cursor.", e);
      throw new SlickException("Failed to set mouse cursor", e);
    }
View Full Code Here

   *      int, int)
   */
  public void setMouseCursor(String ref, int hotSpotX, int hotSpotY)
      throws SlickException {
    try {
      Cursor cursor = CursorLoader.get().getCursor(ref, hotSpotX,
          hotSpotY);
      Mouse.setNativeCursor(cursor);
    } catch (Exception e) {
      Log.error("Failed to load and apply cursor.", e);
    }
View Full Code Here

   *      int, int)
   */
  public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY)
      throws SlickException {
    try {
      Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX,
          hotSpotY);
      Mouse.setNativeCursor(cursor);
    } catch (Exception e) {
      Log.error("Failed to load and apply cursor.", e);
    }
View Full Code Here

      ByteBuffer buffer = ByteBuffer.allocate(image.getWidth()
          * image.getHeight() * 4);
      image.getGraphics().getArea(0, 0, image.getWidth(),
          image.getHeight(), buffer);

      Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX,
          hotSpotY, image.getWidth(), image.getHeight());
      Mouse.setNativeCursor(cursor);
    } catch (Exception e) {
      Log.error("Failed to load and apply cursor.", e);
    }
View Full Code Here

TOP

Related Classes of org.lwjgl.input.Cursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.