• 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

Change sprite frame based on distance from coordinates

 
Greenhorn
Posts: 10
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EDIT: I posted this in Java General as this isn't specifically about Android.

I'm trying to change to different sprite frames based on distance from a move event. How it should work is:

On ACTION_DOWN, check if the x and y coordinates are within a certain area (I'm dealing with bitmaps, so it uses the width and height of the bitmap).

If the x and y coordinates are within the boundary, assign reference variables to the x and y coordinates.

On ACTION_MOVE, rotate the canvas so that it faces the direction of the new coordinates.

Change sprite frame based on distance from coordinates recorded in the ACTION_DOWN event.

There are 16 sprite frames. Ideally, I'd like the formula to taken into account the bitmap dimensions and construct an "invisible circle" at the ACTION_DOWN x and y coordinates. The frame of animation is chosen based upon how far the ACTION_MOVE x and y coordinates are from the circle edge.

Any help is greatly appreciated!

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic