How to check all member of group location

Recommended Posts

Hi i need some help with my school assignment

so what i want to do is to kill the children at the same time if all the children's y position more than 820. or if i can check all the position of the children or the group ( i dont think that possible). 

animals.forEach(function(animal) {   
		   	var z=0;
		   	if (animal.y > 820)
		    { z++;     
			if (z>6)


the number of the children is 5 and the problem is the number of z is always 1 therefor the animal.kill() never been process. 

thought?? or do you have better way to check the position?


really appreciate the help guys thanks 


Share this post

Link to post
Share on other sites

Hey - you need to check "Y" instead of "Z" and then you can remove all of them:
just loop though children as you do and check:


var toRemove = [];
animals.forEach(function(animal) {   
  var z=0;
  if (animal.y > 820){


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.