aspose file tools*
The moose likes Game Development and the fly likes Image shown when player walks over an object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Image shown when player walks over an object" Watch "Image shown when player walks over an object" New topic
Author

Image shown when player walks over an object

Cristian Malmros
Greenhorn

Joined: May 25, 2010
Posts: 2
Hello, hello!

I'm developing a little game at school together with a small group. I'm responsible for graphics but because of deadlines I'll also have to help coding a little now. I'm a total beginner and what I need to do right now for our 2D platform game is to make an image (.png) appear when the player stands at a specific location. I have managed to get images to be shown in-game (with lots of help) but I really have no idea how this should be done.

This is the code to display an image that we've used. Our game is called mimic and here I've placed a sign in the world. I want the text to appear when the player stands at the sign:

mimic.addAnimation("sign_info_",1,true);
mimic.addAnimation("sign_info_",1,false);
mimic.setX(650);
mimic.setY(979);
mimics.add(mimic);

If anyone could help me out I'd be very grateful!
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
Just see if the player (x,y) position is within a certain range of the position you want. If it is then display the image else don't display the image. I'd suggest making the range a constant across the app so you can increase or decrease it as required.


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image shown when player walks over an object
 
Similar Threads
Head First Java Ch. 2 Compile error
Inheritance, how to "upgrade" an instance
OO design question?
Chess Server
Head First Java Book, Chapter 2