简体   繁体   中英

How to make an object disappear when a character touches it and count points?

I am working on a Javascript-based game (with JQuery), where carrots fall from the sky and the rabbit (main character) must collect them.

I have succeeded tomake the carrots fall and to make the rabbit move, but can someone give me an idea on how to make the carrots disappear and add points when the rabbit touches them?

This is my JavaScript code: http://shrib.com/note311876

Thank you.

UPDATE: I think that this plugin https://plugins.jquery.com/overlaps/ might be useful, but don't know what to do. I'm a complete newbie so excuse me.

There are numerous was ways to achieve that. jQuery has some (unofficial) plugins for collision detection:

https://plugins.jquery.com/tag/collision/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM