Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to make Tiled objects collide with the ones on the scene?
Started by Suvoroff Oct 28 2018 11:47 PM

5 replies to this topic
newbie tiled ponytiled
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Suvoroff

[GLOBAL: userInfoPane.html]
Suvoroff
  • Observer

  • 11 posts
  • Corona SDK

Hi everyone!
Corona newb here. I've been struggling with this problem for almost a week now with almost no effect, and it starts to look like I'm simply wasting time. Here's what I'm trying to do: I use Tiled for making maps that have objects on them - how the hell do I get these objects to collide with the ones I create on the scene? There's close to zero information about this online and Sticker Knight's code doesn't help at all, I tried copying it with no effect, got zero clue about how it works there. Can anybody please explain to me how do I do this? I already converted the objects to a physics body. My latest attempt was the following: I added all of the objects from the map to an array in 'scene: create', but when I run a for loop on it, the Simulator tells me the array is nil! How the heck can it be if I successfully print out the length of the array right after I put it all to the array?!

[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,610 posts
  • Corona SDK

You probably need to post what you have so far, otherwise people are just going to be fumbling around in the dark.

[TOPIC: post.html]
#3

Suvoroff

[GLOBAL: userInfoPane.html]
Suvoroff
  • Observer

  • 11 posts
  • Corona SDK

I'll post that as I'll get back to my PC, but I can't see much sense in it, to be honest. A simple advice on how is done is more than enough.

[TOPIC: post.html]
#4

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,610 posts
  • Corona SDK

Well, the short answer is they all need to be physics bodies and added to the same display group. If you've done that, then there is something else wrong that can't be answered without seeing the code.

 

Your issue with the array sounds like a scope problem, but again difficult to confirm without seeing what you're doing.



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,860 posts
  • Corona Staff

You might want to look through these videos:

 

https://www.youtube.com/playlist?list=PLhE_IYaXVf9v7ZRMWQqvCN6dbdTD3YWMn

 

Rob



[TOPIC: post.html]
#6

Suvoroff

[GLOBAL: userInfoPane.html]
Suvoroff
  • Observer

  • 11 posts
  • Corona SDK

Thanks, Nick and Rob, my problem is solved. Although I'll still have a look at those videos, because the problem was that I didn't put both object types to the same display group. Absolutely forgot about that. Thanks a lot, would have never thought about it.
But there's another problem that has emerged, and I don't want to spam the forum with another newb question, so I'll ask it here: how do I address objects in parent scene? I copied the Sticker Knight code again, and it just doesn't work the same way. I'll get to my PC soon and send snippets of my code.


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: newbie, tiled, ponytiled