Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (307)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  collidesWith() method  (Read 6874 times)
0 Members and 1 Guest are viewing this topic.
Offline mizzy

Junior Newbie





« Posted 2010-04-09 05:11:11 »

can anyone explain to me further about this method
1  
2  
boolean collidesWith
(Image, int, int, boolean)


i cant understand much of the two ints in the parameter.
can anyone help me?
Offline zoto

Senior Member


Medals: 4



« Reply #1 - Posted 2010-04-09 05:44:53 »

It would help a lot if you gave some context.
Offline SimonH
« Reply #2 - Posted 2010-04-09 16:58:20 »

http://tinyurl.com/y6w2545

Heroes' Keep is in development.
Meanwhile try Bloodridge
Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline h3ckboy
« Reply #3 - Posted 2010-04-09 18:00:30 »

check the javadoc
Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #4 - Posted 2010-04-09 18:16:23 »

Grin   Haven't seen that before.

I think the answer is 42 though.

Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #5 - Posted 2010-04-09 18:22:32 »

Oh how I love LMGTFY.

See my work:
OTC Software
Offline h3ckboy
« Reply #6 - Posted 2010-04-09 18:26:25 »

yeah, when someone showed me LMGTFY, I bookmarked it Tongue. whoever thought of it is a genious
Offline mizzy

Junior Newbie





« Reply #7 - Posted 2010-04-10 05:35:38 »

my codes for the game is like this

1  
2  
3  
4  
if(spriteA.collidesWith(bulletImage, 18,18, true))
      {
          spriteA=null;
          bulletImage=null;


the bulletImage just overlaps the sprite image
the 18 is the pixel size of the bulletImage.
Did i use this right?
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #8 - Posted 2010-04-10 18:31:24 »

my codes for the game is like this

1  
2  
3  
4  
if(spriteA.collidesWith(bulletImage, 18,18, true))
      {
          spriteA=null;
          bulletImage=null;


the bulletImage just overlaps the sprite image
the 18 is the pixel size of the bulletImage.
Did i use this right?

Quote
collidesWith

public final boolean collidesWith(Sprite s,
                                  boolean pixelLevel)
Checks for a collision between this Sprite and the specified Sprite.
If pixel-level detection is used, a collision is detected only if opaque pixels collide. That is, an opaque pixel in the first Sprite would have to collide with an opaque pixel in the second Sprite for a collision to be detected. Only those pixels within the Sprites' respective collision rectangles are checked.

If pixel-level detection is not used, this method simply checks if the Sprites' collision rectangles intersect.

Any transforms applied to the Sprites are automatically accounted for.

Both Sprites must be visible in order for a collision to be detected.

Parameters:
s - the Sprite to test for collision with
pixelLevel - true to test for collision on a pixel-by-pixel basis, false to test using simple bounds checking.
Returns:
true if the two Sprites have collided, otherwise false
Throws:
NullPointerException - if Sprite s is null

(Note that is from the first Google result).

See my work:
OTC Software
Offline gouessej

JGO Ninja


Medals: 35
Projects: 1


TUER


« Reply #9 - Posted 2010-04-26 11:22:52 »

my codes for the game is like this

1  
2  
3  
4  
if(spriteA.collidesWith(bulletImage, 18,18, true))
      {
          spriteA=null;
          bulletImage=null;


the bulletImage just overlaps the sprite image
the 18 is the pixel size of the bulletImage.
Did i use this right?

Quote
Parameters:
    image - the Image to test for collision
    x - the horizontal location of the Image's upper left corner
    y - the vertical location of the Image's upper left corner
    pixelLevel - true to test for collision on a pixel-by-pixel basis, false to test using simple bounds checking

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
mrbenebob (17 views)
2013-06-19 14:55:23

BrassApparatus (26 views)
2013-06-19 08:52:37

NegativeZero (29 views)
2013-06-19 03:31:52

NegativeZero (32 views)
2013-06-19 03:24:09

Jesse_Attard (35 views)
2013-06-18 22:03:02

HeroesGraveDev (72 views)
2013-06-15 23:35:23

Vermeer (72 views)
2013-06-14 20:08:06

davedes (73 views)
2013-06-14 16:03:55

alaslipknot (65 views)
2013-06-13 07:56:31

Roquen (89 views)
2013-06-12 04:12:32
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!