7 Replies - 1426 Views - Last Post: 19 November 2012 - 07:59 AM

#1 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

bitmap matching

Posted 17 November 2012 - 08:57 AM

I have four bitmaps on screen but only one is correct to touch. The bitmaps have random positions each time the app is run, how can i check that the user touches the right bitmap?
Is This A Good Question/Topic? 0
  • +

Replies To: bitmap matching

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 276
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: bitmap matching

Posted 17 November 2012 - 06:19 PM

Well that all depends on how you are displaying your bitmaps. Can you please provide more info on how you are displaying your bitmaps?
Was This Post Helpful? 0
  • +
  • -

#3 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

Re: bitmap matching

Posted 17 November 2012 - 06:48 PM

Ok then, i use a surface view to display the bitmaps in a for loop and within that for loop is where i check for collisions. What i really want to achieve is shooting down the bitmaps that are on screen but i want only 1 bitmap to be the correct one to be shot. So 4 options but only 1 is correct, i was trying to find a way to identify the correct one. The bitmaps were put in an arraylist
Was This Post Helpful? 0
  • +
  • -

#4 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

Re: bitmap matching

Posted 18 November 2012 - 06:03 AM

keep the coordinates of the correct bitmap for example you displayed the correct bitmap at x,y keep this values in two variables. Then get the point where user touched xpoint, ypoint

if( x <= xpoint && x+correctBitmap.getWidth() >= xpoint && y <=yxpoint && y+correctBitmap.getHeight() >= ypoint ){
userClickedOnCorrectImage();
}


Was This Post Helpful? 1
  • +
  • -

#5 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

Re: bitmap matching

Posted 18 November 2012 - 07:47 AM

Thanks for that suggestion, will try to work round with that. I was also wondering if I should be using an intent to pass extra parameters back to this same activity to allow a different set of bitmaps to be loaded? or just create a class that grabs the new bitmaps?
Was This Post Helpful? 0
  • +
  • -

#6 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

Re: bitmap matching

Posted 18 November 2012 - 12:23 PM

Just create a class, it is much faster and consume lesss resources
Was This Post Helpful? 0
  • +
  • -

#7 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

Re: bitmap matching

Posted 18 November 2012 - 04:15 PM

So using another class in the surface view class to get fresh bitmaps should not be a problem with resources? this is just one component of a main game that I am developing though, how would i switch from this to the main class from the surface view thread?
Was This Post Helpful? 0
  • +
  • -

#8 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

Re: bitmap matching

Posted 19 November 2012 - 07:59 AM

i did not understand the "how would i switch from this to the main class from the surface view thread?" You want to load another set of imaged you do not need to call another intent. If you want to have a menu etc on the surface you have to play with game states. Get the book Beginning Android game or just get the code of the book from here http://code.google.c...-android-games/ to see how you can play with states
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1