AtkinsSJ

Java callbacks and 'this'

Nov 16th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. public class Entity {
  2.     // ...
  3.     public boolean move(int xDifference, int yDifference) {
  4.         // ...
  5.         this.game.animateEntity(this, this.x, this.y, newX, newY, new OnActionCompleted() {
  6.             @Override
  7.             public void completed(Action action) {
  8.                 // How do I access the Entity from here?
  9.                 System.out.println("Action completed!");
  10.             }
  11.         });
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment