Spawned objects colliding differently

Hi guys,

I would very much appreciate your help.

I am building a game in main.lua where objects are spawned on left screen side and are moving to the

right screen size (Landscape mode).

After object passes Right screen side + 100 they are removed from memory via removeSelf() and nil method.

My problem are as follows:

  1. Every other spawned object is colliding differently with the ground.

I assume that every other object is colliding differently because first one is destroyed (removeSelf), so

group anchors are calculated based on number of objects on screen (number of object in player group).

I have tried different things:

  • moving players into one group, and all other objects into another group, and all objects together into

same screenGroup

  • moving main.lua to composer, and using self.view as main group and players as separate group (inserted

in self.view group).

  • using default anchorX, anchorY for players

display.setDefault( “anchorX”, 0 )

display.setDefault( “anchorY”, 0 )

Nothing helps,

How to solve this (how to maintain players group anchor X and anchorY same for each spawned object)?

  1. Another problem.

I have inserted players Runtime and players touch listeners into  playerspawn function

due to spawn function scope.

That is not causing errors during scenes transitions.

Can you explain this?

Should I remove players Runtime and players touch listeners during exit and destroy scene?

Many thanks for your help.

Ivan

@Ivan,

The Spawning Problem

It looks like you might need to let someone look at your code.  

I’m not saying, you should post it all here (please no huge code dumps).  Instead, you might zip it up and post a link.  Then if someone feels like they have the time, they might download it and take a peek.  I am assuming of course, that your code is fairly well organized and formatted so the person who helps doesn’t have to struggle too much.

Alternately, you could post us a short video showing what is happening that is wrong?  Then others might follow up with specific questions or requests for code snippets to help.

If you don’t have a place to put the code, and assuming it is all in main.lua or another single file, you could paste it to a gist: http://gist.github.com/

One Question Per…

I suggest only one question per post, or you’ll end up getting no answers or only one answer.  In any case, it often confuses the effort to help.

Hi roaminggamer,

It is a honor to speak with you.

I have watched several Hangouts where you played.

My code is in composer, so it is rather big.

I have managed to solve this problem by setting all display object anchorX and anchor Y like this:

display.setDefault( “anchorX”, 0.5 )

display.setDefault( “anchorY”, 0.5 )

 

And I deleted previously set ground.anchorX = 0.5, ground.anchorY = 1

So ground anchor was the problem I assume (but it makes no sense…)

Maybe setting all objects anchors globally the same has managed to neutralize players group anchor oscillations.

 

Anyway, I will have to re-type all my code and clean it, so if I do not find another error I will post the code here.

 

Many thanks roaming gamer, I admire your work.

 

Best regards.

Ivan

Aww shucks…  Really though, I’m just a regular guy and sometimes a grumpy one at that (other will attest to this I’m sure).    :slight_smile:

Best of luck on this, and be sure to post back if you get stuck again.  

@Ivan,

The Spawning Problem

It looks like you might need to let someone look at your code.  

I’m not saying, you should post it all here (please no huge code dumps).  Instead, you might zip it up and post a link.  Then if someone feels like they have the time, they might download it and take a peek.  I am assuming of course, that your code is fairly well organized and formatted so the person who helps doesn’t have to struggle too much.

Alternately, you could post us a short video showing what is happening that is wrong?  Then others might follow up with specific questions or requests for code snippets to help.

If you don’t have a place to put the code, and assuming it is all in main.lua or another single file, you could paste it to a gist: http://gist.github.com/

One Question Per…

I suggest only one question per post, or you’ll end up getting no answers or only one answer.  In any case, it often confuses the effort to help.

Hi roaminggamer,

It is a honor to speak with you.

I have watched several Hangouts where you played.

My code is in composer, so it is rather big.

I have managed to solve this problem by setting all display object anchorX and anchor Y like this:

display.setDefault( “anchorX”, 0.5 )

display.setDefault( “anchorY”, 0.5 )

 

And I deleted previously set ground.anchorX = 0.5, ground.anchorY = 1

So ground anchor was the problem I assume (but it makes no sense…)

Maybe setting all objects anchors globally the same has managed to neutralize players group anchor oscillations.

 

Anyway, I will have to re-type all my code and clean it, so if I do not find another error I will post the code here.

 

Many thanks roaming gamer, I admire your work.

 

Best regards.

Ivan

Aww shucks…  Really though, I’m just a regular guy and sometimes a grumpy one at that (other will attest to this I’m sure).    :slight_smile:

Best of luck on this, and be sure to post back if you get stuck again.