所以我的类扩展了Actor,我想使用方法getLocation(),它需要来自Actor的Location,但它将我发送到需要Point的java.awt.Point的getLocation()
public class Myplayer extends Actor
Location myLocation = player.getLocation();
错误:
incompatible types: java.awt.Point cannot be converted to ch.aplu.jgamegrid.Location
以下是两个图书馆的链接:
演员:http://www.aplu.ch/classdoc/jgamegrid/index.html
的getLocation
public Location getLocation()
Returns the current location (horizontal and vertical coordinates).
Returns:
a clone of the current location (cell indices)
点:http://docs.oracle.com/javase/7/docs/api/java/awt/Point.html#getLocation%28%29
的getLocation
public Point getLocation()
Returns the location of this point. This method is included for completeness,
to parallel the getLocation method of Component.
Returns:
a copy of this point, at the same location
如何在不使用Point的情况下解决这个问题?
编辑:
import ch.aplu.jgamegrid.*;
import java.awt.Color;
import java.util.*;
public class MyPlayer extends Actor
private Players player
public Location myLocation() {
return player.getLocation();
答案 0 :(得分:0)
Player类继承了Actor的所有方法,因为我发现getLocation()只能由它自己使用而不需要调用对象引用。