Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : PShape() - significant performance issues

$
0
0
In the code above, yes, but I'm rewriting the code as per your suggestion. Now my main method looks like this:
  1. PShape kick;
  2. float kickx = 60;
  3. float kicky = 60;

  4. Drums drums;

  5. void setup(){
  6.   size(960,540,P2D);
  7.   frameRate(25);
  8.   smooth();
  9.   
  10.   float centerx = width/2;
  11.   float centery = height/2;
  12.   
  13.   kick = createShape(ELLIPSE, centerx, centery, kickx, kicky);  
  14.   
  15.   drums = new Drums(kick);
  16. }

  17. void draw(){
  18.   background(0);
  19.   
  20.   drums.run();
  21. }


And my class, Drum, looks like this: 

  1. public class Drums{    
  2.        
  3.     Drums(PShape _kick){
  4.       PShape kick = _kick;
  5.     }
  6.     
  7.     public void run(){
  8.       if(running){
  9.         display();
  10.         shrink();
  11.       }
  12.     }

  13.     public void display(){
  14.         stroke(255);
  15.         fill(255,255,255);
  16.  
  17.         shape(kick);
  18.     }

  19.     public void shrink(){  
  20.       kick.scale(0.02);  
  21.     }
  22. }

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?

Viewing all articles
Browse latest Browse all 1768

Trending Articles