This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

Image shown when player walks over an object

Cristian Malmros

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:


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

Joined: Jun 28, 2009
Posts: 260
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:
subject: Image shown when player walks over an object
It's not a secret anymore!