In the code above, yes, but I'm rewriting the code as per your suggestion. Now my main method looks like this:
- PShape kick;
- float kickx = 60;
- float kicky = 60;
- Drums drums;
- void setup(){
- size(960,540,P2D);
- frameRate(25);
- smooth();
- float centerx = width/2;
- float centery = height/2;
- kick = createShape(ELLIPSE, centerx, centery, kickx, kicky);
- drums = new Drums(kick);
- }
- void draw(){
- background(0);
- drums.run();
- }
And my class, Drum, looks like this:
- public class Drums{
- Drums(PShape _kick){
- PShape kick = _kick;
- }
- public void run(){
- if(running){
- display();
- shrink();
- }
- }
- public void display(){
- stroke(255);
- fill(255,255,255);
- shape(kick);
- }
- public void shrink(){
- kick.scale(0.02);
- }
- }
If I run the code above, the circles appear as per expected. However, it does not behave at all like I expected; the kick shape moves across the screen. I want it to stay static. How do I achieve this?