0

So my class extends Actor, and I want to use the method getLocation() which requires Location from Actor, but it sends me to getLocation() of java.awt.Point which requires Point

public class Myplayer extends Actor
Location myLocation = player.getLocation();

The Error:

incompatible types: java.awt.Point cannot be converted to ch.aplu.jgamegrid.Location

Here are links to the two libraries:

Actor: 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)

Point: 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

How I can fix this, without using Point?

EDIT:

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();
  • 2
    Please show the definition of `getLocation` in myplayer, and the definition of the `player` variable. It would be better to post your full classes, removing only methods that you are positive that are not relevant. – RealSkeptic Nov 30 '14 at 11:53
  • 1
    Also post what you import in myplayer class – Hana Bzh Nov 30 '14 at 11:59
  • It would be better to edit your question, as it would be more readable. Also you should post your relevant classes. – meskobalazs Nov 30 '14 at 12:11
  • 1
    Well then, now that you have edited, we can see that player is not of type `MyPlayer`. So it doesn't matter whether `MyPlayer` extends `Actor` or not. If you really want further assistance, you have to explain your real problem, and post your full code, explaining *within context* what is going wrong. – RealSkeptic Nov 30 '14 at 12:16

1 Answers1

0

The class Player inherits all methods of Actor, because of that I found that getLocation() can be used only by itself without calling an object reference.