The Daily Click ::. Forums ::. Klik Coding Help ::. Testing Number of Objects
 

Post Reply  Post Oekaki 
 

Posted By Message

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 07:14:01 -

Hi,

Is it possible to somehow detect how many objects are overlapping another object? I know you can do this within a fixed zone, but I want it for a moving object. Thanks to anyone who can help.

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
5th April, 2011 at 11:54:30 -

Perhaps when the object is overlapping the object, set an alterable value to 1. Then have another event which tests all the objects which have that alterable value that equals 1. The "Create new objects" icon has a condition which lets you "Pick objects with reference to their value".


edit: LOL, that wasn't relevant at all, sorry.

Edited by alastair john jack

 
lol

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
5th April, 2011 at 12:28:24 -

Select Object Extension.

Active A is overlapping Active B:
> Counter = numSelectedByName( "Select Object Extension", "Active A")

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 12:51:26 -

I can't find the Select Object Extension anywhere for download. Where is it?

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 13:07:39 -

Don't worry, I found it.

Edit: Doesn't seem to be working though. It doesn't seem to be setting the value of the selected object...

Edited by vetmora120

 
n/a

Zephni

My other cars a Balrog

Registered
  17/10/2007
Points
  4019

Has Donated, Thank You!VIP MemberSonic Speed
5th April, 2011 at 13:49:57 -

Would be better if you done it without an extension anyway, have tried what alastair said or somthing similar?

 
dont make me divide by zero...

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 14:08:39 -

Yeah what alistair said works, but I can't find a way to actually get the number of object that are overlapping another object.

 
n/a

Zephni

My other cars a Balrog

Registered
  17/10/2007
Points
  4019

Has Donated, Thank You!VIP MemberSonic Speed
5th April, 2011 at 14:32:18 -

make a fastloop that runs the same amount of times as the amount of objects that could overlap. Then do:

+on fastloop
+and 'active ob' alt val a = 1

- add 1 to another variable somewhere.

Then that variable will be equal to the amount that are overlapping at all times.

 
dont make me divide by zero...

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 14:47:00 -

I'm sorry for my ignorance. But this is just not making sense for me...

What I've got so far is:

+always
-start loop number of object A times

+on loop
+object A flag is on
-add 1 to counter

+object A is overlapping object B
-set object A flag on

+object A is NOT overlapping object B
-set object A flag off

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
5th April, 2011 at 16:04:05 -

It won't work, because of the way MMF2 scopes objects. The easiest way to do this is definitely the Select Object Extension, which can do it with a single line of code like he said.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 16:21:24 -

Oh, how unfortunate. The extension still won't work for me in HWA. Any ideas?

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
5th April, 2011 at 16:25:55 -

Oh, yeah, HWA, that would do it.

Well you'd need to run an fastloop that iterates through every single instance of the 2nd object, and then counts if its overlapping the first object. If the objects are of the same class, use a detector thats placed over the object you're testing to simplify it. Use the "foreach" object instead of fast loops, to speed it up alot

Set counter to 0
Start a foreach loop for object #2
On Foreach loop for object #2, If object #2 is overlapping object #1, add 1 to the counter

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

vetmora120



Registered
  07/01/2010
Points
  273
5th April, 2011 at 16:54:19 -

AHA! Works magically. Thanks for all your help everyone ;D

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
5th April, 2011 at 17:01:56 -

no problems sir
Image



 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Ricky

loves Left For Dead 2

Registered
  28/12/2006
Points
  4175

Has Donated, Thank You!Game of the Week WinnerVIP MemberWii OwnerHero of TimeGOTM Winner! - November 2009I am an April Fool
5th April, 2011 at 20:08:03 -

pixle thief you made me brush off my screen for no reason

 
-
   

Post Reply



 



Advertisement

Worth A Click