Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Can I have a collision answer?
Started by david.hutyra.stp Feb 11 2020 02:01 PM

4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

david.hutyra.stp

[GLOBAL: userInfoPane.html]
david.hutyra.stp
  • Observer

  • 12 posts
  • Corona SDK

I want for my game to be like bloonsTD in that once a bullet hits the zombie it does a bit of damage and after certain amounts of damage it disappears. Can someone show me the coding to have collisions do something like that?



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,176 posts
  • Corona SDK

Hey David!

It seems like you are asking a lot of rudimentary questions at once. I like your enthusiasm, but I would suggest that you take a moment to get acquainted with the basics first.

Corona has a fantastic set of tutorials that you could take a look at. First, here's some general Lua tips with Corona in mind: https://docs.coronalabs.com/tutorial/. Then here are a few simple Corona projects you could take a look at: https://docs.coronalabs.com/guide/programming/index.html.

 

You can also find simple sample projects, along with their source code, by opening Corona simulator and opening the help tab, then navigate to sample projects. For instance, there's an entire section for physics sample projects, such as CollisionDetection and CollisionFilters that might provide you with the answers that you seek here.

 

Finally, Corona Docs is a great resource for most questions like these. You can find extensive examples on topics like collision detection there, just type "corona sdk collision detection" to Google and you'll get https://docs.coronalabs.com/guide/physics/collisionDetection/index.html.

 

If we'd copy the approach from the docs, you'd 1) create a display object, 2) give it a value like, "object.currentHP = 5" and then 3) you'd give it a collision listener, but instead of printing the object's name, you'd always deduct 1 HP from it. Then you'd have a simple conditional statement that checks if the object has more 0 HP left. If it doesn't, you remove it.

 

You are just starting to learn how to code, so it's best to learn it by yourself instead of having someone write some code that sort of works, but that you'd need to rewrite later on anyway. Happy coding!


  • roaminggamer and pixec like this

[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

I second the above advice.

 

After getting a fundamental understanding of Lua + Corona + Game coding in general, you might consider downloading:


  • pixec likes this

[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

I forgot one:

 

https://forums.coronalabs.com/topic/74704-template-portfolio-release/



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

While not a tower defense mechanic, this answer has some parts of what you want.

 

https://forums.coronalabs.com/topic/72342-make-transition-react-to-collsion-contact/


  • pixec likes this


[topic_controls]
[/topic_controls]