问题
i want to make square shape to be able to move on rectangle shape below it relative to it rotation. please check my code here https://editor.p5js.org/saidabdul80/sketches/-Adu8HzFZ
回答1:
@Said Abdulsalam I think the answer to your question is this. you should move the one object with the same vareable as the the other.
eg:
//rot for object 1
int rotY =0;
void draw (){
// object 1
rectMode(center);
popmatrix();
rotate(rotY);
rect(X,Y,20,20);
pushMatrix();
// object moving relative to object 1
rect(rotY,500,20,20);
rotY++;
}
this will rotate rect 1 and move rect2.
来源:https://stackoverflow.com/questions/65923743/how-do-i-make-shape-move-relatively-on-another-shape-p5-js