We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how rotate two images independly
Page Index Toggle Pages: 1
how rotate two images independly ? (Read 623 times)
how rotate two images independly ?
Sep 21st, 2009, 2:06pm
 
hello,

I can rotate one shape object on its center, but can't make it work with several objects : first object is ok but seconds rotates both on itself and around first object too.
Here is the class of the should-be rotating objects :
Code:
class svgStar { 

       float xPos;
       float yPos;
       float fxSpeed;

       svgStar(float tempXpos, float tempYpos, float tempXspeed) {
               xPos            = tempXpos;
               yPos            = tempYpos;
               fxSpeed         = tempXspeed;
       }

       void display() {

               shape(svgStar, -wheelWidth/PI,-wheelHeight, wheelWidth, wheelHeight);
       }

       void move() {
                             
               angle +=0.1;
               cosine = cos(angle);

               translate(xPos,yPos);
               rotate(angle/5);

       }

}


Setup :
Code:
     myStar1 = new svgStar(20,20,1);
       myStar2 = new svgStar(100,100,1);
       
       
       

Draw :
Code:
        myStar1.move();
       myStar1.display();
       myStar2.move();
       myStar2.display();

Apologies for my english.
Re: how rotate two images independly ?
Reply #1 - Sep 21st, 2009, 2:16pm
 
Have a look at pushMatrix Wink
Re: how rotate two images independly ?
Reply #2 - Sep 21st, 2009, 4:56pm
 
look ye also into popMatrix!
Page Index Toggle Pages: 1