Hilfe bei GameGrid

  • Themenstarter Themenstarter Bengaltiger
  • Beginndatum Beginndatum
B

Bengaltiger

Gast
Hallo

ich programmiere grad ein mini spiel mit GameGrid von aplu.

doch ich komme grad nicht weiter.
-----------------------------------------------------------------------------------------------------------------
getOneActor

public Actor getOneActor(java.lang.Class clazz)

Returns the first actor of specified class in the actor's list. Useful when only one actor of the specified class is present. The actor is considered to have the type of its superclasses too.

Parameters:
clazz - the class of the actors to look for, if null all actors are considered
Returns:
the first actor in the actor's list or null, if no actor is found
--------------------------------------------------------------------------------------------------------------------
->das kann ich deklarieren indem ich Actor beispiel= gameGrid.getOneActor(Bespiel.class); schreibe
-------------------------------------------------------------------------------------------------------------------
getActors

public java.util.ArrayList<Actor> getActors(java.lang.Class clazz)

Returns all actors of the specified class. The actor is considered to have the type of its superclasses too.

Parameters:
clazz - the class of the actors to look for, if null all actors are returned
Returns:
an ArrayList that contains actors of the given class
----------------------------------------------------------------------------------------------------------------------
-> bei dem weis ich es nicht wie man das machen kann


weis einer ne lösung?

Dane voraus
 
also
nach dem ich java.util.list importiert hab
geht List<Actor> bespiel=gameGrid.getActors(Beispiel.class);

doch ich möchte es jetzt hier werwenden

fisch.addActorCollisionActor(hier drin soll jetzt beispiel stehen); doch komt diese fehler,eldung

method addCollisionActor in class ch.aplu.jgamegrid.Actor cannot be applied to given types
required: ch.aplu.jgamegrid.Actor
found: java.util.List<ch.aplu.jgamegrid.Actor>


was nun kann mans umschreiben?
 
hab es gelöst man musste nur das s nach dem CollisionsActor anhängen

doch hab schon ein neues problem

mein actor soll sich wie die funktion 1/9000*(x-300)³+300 bewegen

doch dass klapptnet so, mit lineare funktionen geht es wie 2x+1

hab es so probiert:

int x=getX();
private void route(){
setX(x);
setY((int)(1/9000*Math.pow(x-300,3)+300));
x=getX()+1;}

für jede hilfe dankbar =)
 
Teste mal das hier:
Java:
System.out.println(1/9000);
Und dann das hier:
Java:
System.out.println(1d/9000);
 
Das sollte durch das Math.pow eigentlich schon erledigt sein. Aber ansonsten steht da zu wenig code, als dass man etwas genaueres sagen könnte....
 
Eigentlich. 😀
Es wird doch von links nach rechts ausgewertet,
Code:
1/9000
ist also noch in
Code:
int
.
 

Zurück
Oben