Grip / update()

import compose.grips.*;

GripDispatcher dispatch;
SquareGrip myGrip;

void setup() {
  dispatch = new GripDispatcher(this);
  myGrip = new SquareGrip(50, 50, 40);
}

void draw() {
  dispatch.update(); // Checks for hover
  dispatch.draw(); // Calls all the draw methods
}

class SquareGrip extends Grip {

  float x, y, s;
  float rotation;

  SquareGrip(float x, float y, float s) {
    this.x = x;
    this.y = y;
    this.s = s;
    this.rotation = 0;
  }
  
  void update() {
    rotation += radians(1);
  }

  void draw() {
    pushMatrix();
    translate(x, y);
    rotate(rotation);
    rect(-s/2, -s/2, s, s);
    popMatrix();
  }

}

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Description

Arbitrary code that runs every frame, before the GripDispatcher picks a new hover.

Syntax
class FancyGrip extends Grip {
   void update() { 
     statements
   }
}
Parameters
None
Returns
None
Usage
Web & Applications
Related
Last Modified: January 25, 2010

No Comments

You must be logged in to post a comment.