processing 根据物体移动方向改变朝向
PVector dir; void setup() { size(500, 500); rectMode(CENTER); } void draw() { background(100); dir = new PVector(mouseX, mouseY).sub(new PVector(pmouseX,pmouseY)); translate(mouseX,mouseY); rotate(dir.heading()); //rotate(atan2(dir.y,dir.x)); rect(0, 0, 100,50); }
*注:在processing中,物体默认朝向为X轴正方向,即右边。
posted on 2019-02-21 11:46 吾少也贱,故能多鄙事。 阅读(471) 评论(0) 编辑 收藏 举报