[Pogamut-list] Projectile Speed
michal.bida
pogamut-forum at artemis.ms.mff.cuni.cz
Mon Apr 6 20:19:02 CEST 2009
Re: Projectile Speed
Author: michal.bida
The speed attribute is already in IncomingProjectile class. Why would you count it yourself? Just register listener pro IncomingProjectile messages and get it from there.
Code:
//Your listener class, where you process PRJ messages
RcvMsgListener myListener = new RcvMsgListener() {
@Override
public void receiveMessage(RcvMsgEvent e) {
double speed;
IncommingProjectile prj;
prj = (IncommingProjectile) e.getMessage();
speed = prj.speed;
}
};
//In postPrepareAgent method you register your listener, so Projectile messages will be sent to it.
@Override
protected void postPrepareAgent(){
this.getBody().addTypedRcvMsgListener(myListener, MessageType.INCOMMING_PROJECTILE);
}
best,
michal
More information about the Pogamut-list
mailing list