极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13869|回复: 5

关于processing的问题

[复制链接]
发表于 2016-4-9 18:53:33 | 显示全部楼层 |阅读模式
本帖最后由 lonelyman 于 2016-4-16 18:19 编辑

   最近在学习使用AI_FOR 2D_gaming的库,但是在编译官网给出的源代码是报错,请大家帮忙看一下,错误出在哪里,谢谢!!!
  1. import game2dai.*;
  2. import game2dai.entities.*;
  3. import game2dai.entityshapes.*;
  4. import game2dai.entityshapes.ps.*;
  5. import game2dai.fsm.*;
  6. import game2dai.graph.*;
  7. import game2dai.maths.*;
  8. import game2dai.steering.*;
  9. import game2dai.utils.*;
  10. World world;
  11. StopWatch sw;
  12. Vehicle tank;
  13. Vector2D target = new Vector2D();
  14. BitmapPic view;

  15. public void setup() {
  16.   size(600, 320);
  17.   world = new World(width, height);
  18.   sw = new StopWatch();
  19.   // Create the mover
  20.   tank = new Vehicle(new Vector2D(width/2, height/2), // position
  21.     40,                 // collision radius
  22.     new Vector2D(0, 0), // velocity
  23.     40,                 // maximum speed
  24.     new Vector2D(1, 0), // heading
  25.     15,                 // mass
  26.     1.5f,               // turning rate
  27.     1000                // max force
  28.   );
  29.   // What does this mover look like
  30.   view = new BitmapPic(this,"tanks.png", 8, 1, 0);   
  31.   view.showHints(Hints.HINT_COLLISION | Hints.HINT_HEADING | Hints.HINT_VELOCITY);
  32.   tank.renderer(view);
  33.   // Finally we want to add this to our game domain
  34.   world.add(tank);
  35.   sw.reset();
  36. }

  37. public void draw() {
  38.   double elapsedTime = sw.getElapsedTime();
  39.   target.set(mouseX, mouseY);
  40.   tank.AP().arriveOn(target);
  41.   float speed = (float) tank.speed();
  42.   float maxSpeed = (float) tank.maxSpeed();   
  43.   if (speed > 1) {
  44.     float newInterval = map(speed, 0, maxSpeed, 0.6, 0.04);
  45.     view.setAnimation(newInterval, 1);
  46.   }
  47.   else {
  48.     view.pauseAnimation();
  49.   }
  50.   world.update(elapsedTime);
  51.   background(218, 140, 54);
  52.   world.draw(elapsedTime);
  53. }
复制代码

以下是错误信息:d.pde:31:0:31:0: The constructor BitmapPic(d, String, int, int, int) is undefined
回复

使用道具 举报

发表于 2016-4-12 00:41:50 | 显示全部楼层
game2dai这个库你没有吧。在Libraries里面找找看。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-4-15 17:59:48 | 显示全部楼层
seagatecm 发表于 2016-4-12 00:41
game2dai这个库你没有吧。在Libraries里面找找看。

我已经找到了AI_for_2d_gaming,但不知如何查看是否缺少game2dai这个库,请问我要如何查看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-4-15 19:10:12 | 显示全部楼层
附上该库的下一级文件夹的截图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2016-4-16 13:19:57 | 显示全部楼层
我知道为什么了,文档里面说明BitmapPic的构造函数只有4个参数。你给了5个。
Constructors
Constructor and Description

BitmapPic(PApplet papp, String fname)
Single image for all frames

BitmapPic(PApplet papp, String fname, int nCols, int nRows)
An animated image.
把后面的0去掉吧。

view = new BitmapPic(this,"tanks.png", 8, 1);

你可以在 菜单 帮助 - 库文件参考 里面看到这个帮助文档。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-4-16 18:06:20 | 显示全部楼层
seagatecm 发表于 2016-4-16 13:19
我知道为什么了,文档里面说明BitmapPic的构造函数只有4个参数。你给了5个。
Constructors
Constructor  ...

成功了,感谢大神的指导!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-29 06:55 , Processed in 0.068278 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表