1 decade ago by dungeonmaster
I have two entities : fish and food.
I want to detect wheter the fish collided with the food (touched) and if so remove the food.
Fish has two states, hungry or full. If the fish is full, then it shouldn't touch nor collide with the food. All fish start as hungry and become full if they touch the food. I overwrote its collideWith like this. (isFood is a custom property I added)
I set colisions of entityFood as .LITE and entityFish as .ACTIVE. I've also overwritten collideWith of food to not have it move like this:
Problem 1) If a fish is full and it touches food. It pushes the food away. I want the food to just stay in it's position without actually colliding.
Problem 2) The fishes collide with each other. I don't want it either.
Any ideas?
I want to detect wheter the fish collided with the food (touched) and if so remove the food.
Fish has two states, hungry or full. If the fish is full, then it shouldn't touch nor collide with the food. All fish start as hungry and become full if they touch the food. I overwrote its collideWith like this. (isFood is a custom property I added)
collideWith: function( other, axis ) { if (other.isFood && this.hunger > 900) { other.kill(); this.hunger = 0; } },
I set colisions of entityFood as .LITE and entityFish as .ACTIVE. I've also overwritten collideWith of food to not have it move like this:
collideWith: function( other, axis ) { // Don't do anything stupid },
Problem 1) If a fish is full and it touches food. It pushes the food away. I want the food to just stay in it's position without actually colliding.
Problem 2) The fishes collide with each other. I don't want it either.
Any ideas?