作者 主题: 新手求教 我这样写有什么问题  (阅读 3797 次)

calvinhuang

  • Newbie
  • *
  • 帖子: 8
新手求教 我这样写有什么问题
« 于: 十一月 15, 2011, 05:07:31 下午 »
这样调用类有什么问题吗?
程序代码
Damper myDamper;
void setup(){
  size(300,600);
  myDamper=new Damper(mouseX,mouseY);
}
void draw(){
  background(255);
  myDamper.display();
  myDamper.movement();
}
程序代码
class Damper {
  color c;
  float xpos;
  float ypos;
  int w;
  int h;
  Damper(float xpos_, float ypos_) {
    c=color(100, 255, 255);
    xpos=xpos_;
    ypos=ypos_;
    w=80;
    h=10;
  }
  void display() {
    rectMode(CENTER);
    fill(c);
    noStroke();
  }
  void movement() {
    rect(xpos, ypos, w, h);
  }
}

RavenKwok

  • Sr. Member
  • ****
  • 帖子: 277
  • Artist/ Animator/ Coder/ Cynical Asshole
Re: 新手求教 我这样写有什么问题
« 回复 #1 于: 十一月 15, 2011, 06:17:45 下午 »
为何绘制矩形的函数,你要归在你定义的movement 内?

Tags: