• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image shown when player walks over an object

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 287
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic