我如何使形状在另一个形状上相对移动 p5.js [英] how do i make shape move relatively on another shape p5.js

查看:45
本文介绍了我如何使形状在另一个形状上相对移动 p5.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让方形能够相对于它的旋转在它下面的矩形上移动.请在这里检查我的代码https://editor.p5js.org/saidabdul80/sketches/-Adu8HzFZ

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

推荐答案

@Said Abdulsalam 我认为您的问题的答案是这样的.您应该使用与另一个相同的变量移动一个对象.

@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.

例如:

 //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++;
 }

这将旋转 rect 1 并移动 rect2.

this will rotate rect 1 and move rect2.

这篇关于我如何使形状在另一个形状上相对移动 p5.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆