百度空间 | 百度首页 
               
 
查看文章
 
robocode部分API中文参考(6)
2008年10月29日 星期三 16:59

onWin    当胜利时
public void onWin(WinEvent event)
This method is called if your robot wins a battle.
Your robot could perform a victory dance here! :-)
当你的机器人赢了战斗时这个方法会被调用,你的机器人能在这时跳一个支胜利之舞!

Specified by:
onWin in interface IBasicEvents
Parameters:
event - the win event set by the game
参数值是游戏设定的
See Also:
WinEvent, Event

--------------------------------------------------------------------------------

scan     扫描
public void scan()
Scans for other robots. This method is called automatically by the game, as long as the robot is moving, turning its body, turning its gun, or turning its radar.
Scan will cause onScannedRobot(ScannedRobotEvent) to be called if you see a robot.
扫描其它机器人。这个方法是游戏自动调用的,每当你的机器人在移动时,转动它的身体时,转动它的枪时,或是转动它的雷达时。
扫描会在看到一个机器人时调用onScannedRobot(ScannedRobotEvent)方法。

There are 2 reasons to call scan() manually:
有两个要手动调用scan()的原因:
You want to scan after you stop moving.
You want to interrupt the onScannedRobot event. This is more likely. If you are in onScannedRobot and call scan(), and you still see a robot, then the system will interrupt your onScannedRobot event immediately and start it from the top.
This call executes immediately.
在你停止移动时你想扫描。
你想中断 onScannedRobot 事件。这种似乎更有可能。如果你在onScannedRobot中调用scan(),并且你仍看到一个机器人,那么系统会马上中断你的onScannedRobot事件,并从开始处执行它。
这个调用会马上执行。


See Also:
onScannedRobot(ScannedRobotEvent), ScannedRobotEvent

--------------------------------------------------------------------------------

setAdjustGunForRobotTurn     
public void setAdjustGunForRobotTurn(boolean independent)
Sets the gun to turn independent from the robot's turn.
使枪独立于机器人转动。
Ok, so this needs some explanation: The gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, then the gun will turn with it as it is mounted on top of the robot's body. To compensate for this, you can call setAdjustGunForRobotTurn(true). When this is set, the gun will turn independent from the robot's turn, i.e. the gun will compensate for the robot's body turn.
好的,这就要一些解释了:枪是固定在机器人上的。因此,一般来说,如果机器人向右转90度,枪也会因为架在机器人上而转动。作为一种补偿,你可以调用setAdjustGunForRobotTurn(true),当这个被设定时,枪会独立于机器人转动。

Example, assuming both the robot and gun start out facing up (0 degrees):
例如,设你的机器人和枪在开始时都向上(0度角)。

   // Set gun to turn with the robot's turn
设置使枪和机器人一起转
   setAdjustGunForRobotTurn(false); // This is the default 这是默认的
   turnRight(90);
   // At this point, both the robot and gun are facing right (90 degrees)
在这一点,机器人和枪都面向右边(90度角)。
   turnLeft(90);
   // Both are back to 0 degrees
都回到0度角

   -- or --或者

   // Set gun to turn independent from the robot's turn
设置使枪独立于机器人转动
   setAdjustGunForRobotTurn(true);
   turnRight(90);
   // At this point, the robot is facing right (90 degrees), but the gun is still facing up.
在这一点,机器人面向右,但枪面向上
   turnLeft(90);
   // Both are back to 0 degrees.
它们都回到0度角
Note: The gun compensating this way does count as "turning the gun". See setAdjustRadarForGunTurn(boolean) for details.
注意:枪独立的这种方式被认为是 转动枪。要更详细,请看setAdjustRadarForGunTurn(boolean)

Parameters:
independent - true if the gun must turn independent from the robot's turn; false if the gun must turn with the robot's turn.
independent - true 如果枪必须独立于机器人而转动;false 如果枪必须随着机器人转动。
See Also:
setAdjustRadarForGunTurn(boolean)

--------------------------------------------------------------------------------

setAdjustRadarForRobotTurn
public void setAdjustRadarForRobotTurn(boolean independent)
Sets the radar to turn independent from the robot's turn.
设置使雷达独立于机器人转动
Ok, so this needs some explanation: The radar is mounted on the gun, and the gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, the gun turns, as does the radar. Hence, if the robot turns 90 degrees to the right, then the gun and radar will turn with it as the radar is mounted on top of the gun. To compensate for this, you can call setAdjustRadarForRobotTurn(true). When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the robot's turn.
好的,这就要一些解释了:雷达是固定在枪上的,枪是固定在机器人上的。因此,一般来说,如果机器人向右转90度,枪也会因为架在机器人上而转动,雷达也一样。因此,如果机器人向右转90度,那么枪和雷达会一起转,因为雷达因定在枪上。作为一种补偿,你可以调用setAdjustGunForRobotTurn(true),当这个被设定时,枪会独立于机器人转动。

Example, assuming the robot, gun, and radar all start out facing up (0 degrees):
例如,设你的机器人和枪,雷在开始时都向上(0度角)。

   // Set radar to turn with the robots's turn
设置使雷达和机器人一起转
   setAdjustRadarForRobotTurn(false); // This is the default   这是默认的
   turnRight(90);
   // At this point, the body, gun, and radar are all facing right (90 degrees);
在这一点,机器人和枪,雷达都面向右边(90度角)。

都回到0度角

   -- or --或者

   // Set radar to turn independent from the robot's turn
设置使雷达独立于机器人转动
   setAdjustRadarForRobotTurn(true);
   turnRight(90);
   // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up.
在这一点,机器人和枪面向右(90度角),但雷达仍向上。

Parameters:
independent - true if the radar must turn independent from the robots's turn; false if the radar must turn with the robot's turn.
参数
independent - true 如果雷达必须独立于机器人转动, false 如果雷达必须和机器人一起转动
See Also:
setAdjustGunForRobotTurn(boolean), setAdjustRadarForGunTurn(boolean)

--------------------------------------------------------------------------------

setAdjustRadarForGunTurn
public void setAdjustRadarForGunTurn(boolean independent)
Sets the radar to turn independent from the gun's turn.
使雷达独立于枪转动。
Ok, so this needs some explanation: The radar is mounted on the robot's gun. So, normally, if the gun turns 90 degrees to the right, then the radar will turn with it as it is mounted on top of the gun. To compensate for this, you can call setAdjustRadarForGunTurn(true). When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the gun's turn.
好的,这就要一些解释了:雷达是固定在枪上的。因此,一般来说,如果枪向右转90度,雷达也会因为架在枪上而转动。作为一种补偿,你可以调用setAdjustRadarForGunTurn(true),当这个被设定时,雷达会独立于枪转动。


Example, assuming both the gun and radar start out facing up (0 degrees):
例如,设你的枪和雷达在开始时都向上(0度角)。

   // Set radar to turn with the gun's turn
设置使雷达和枪一起转
   setAdjustRadarForGunTurn(false); // This is the default 这是默认的
   turnGunRight(90);
   // At this point, both the radar and gun are facing right (90 degrees);
在这一点,雷达和枪都面向右边(90度角)。
都回到0度角

   -- or --或者

   // Set radar to turn independent from the gun's turn
设置使雷独立于枪转动
   setAdjustRadarForGunTurn(true);

   turnGunRight(90);
   // At this point, the gun is facing right (90 degrees), but the radar is still facing up.
在这一点,枪面向右,但雷达面向上
Note: Calling setAdjustRadarForGunTurn(boolean) will automatically call setAdjustRadarForRobotTurn(boolean) with the same value, unless you have already called it earlier. This behavior is primarily for backward compatibility with older Robocode robots.
请注意:调用setAdjustRadarForGunTurn(boolean)时会自动用同样的参数调用setAdjustRadarForRobotTurn(boolean),除非你已经调用过setAdjustRadarForRobotTurn(boolean)。这主要是为了向后兼容旧的机器人。

Parameters:
independent - true if the radar must turn independent from the gun's turn; false if the radar must turn with the gun's turn.
参数
independent - true 如果雷达必须独立于枪转动, false 如果雷达必须和枪一起转动
See Also:
setAdjustRadarForRobotTurn(boolean), setAdjustGunForRobotTurn(boolean)


类别:Robocode | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu