Question about setGravity

Hi again! I got a little confused with your code, although it is clearly more efficient than mine.

What I need to do is something like this:

Once a “ball” collides with an object (let’s say a bar), a red cross should appear for one second, fading out until it “dissapear” (indication of a mistake).

I have several “balls” that will collide with this “bar”, and every time this happens, the object “red cross” should appear and fade out in one second.

The only way I found to solve this was using a “local object redCross” inside the function.

This works perfectly, but once I collide the “right ball” with the “bar”, I should change the scene and return to the previous one.

Once I see the previous one, the object “red cross” magically appears and disappear again.

I guess this is because of the fact that my “red cross” is not added to the scene, cause it’s a local variable in a function, right?

I tried adding the “function that contains the red cross local object” in the scene, but it gives me an error, and/or I couldn’t know how to do it.

Perhaps now it’s more clear what I need.

Thanks again!!

I am still not clear on what you’re trying to do.

So I made up a example that demonstrates one way to handle scope and visibility in composer scenes.

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/10/redcross.zip

Be aware, this example uses my custom composer scene which splits show/hide into willShow/didShow and willHide/didHide events.

I hope by looking at what I’ve done here you can get a better understanding of how scope and visibility works in composer scenes, and that with that info you can proceed.

OK I’ll take a look at your project.

Thanks!

Hi again! I was checking your code and it is really good!

What I need to do in this case is:

Instead of going from scene2 to scene1 when I “touch” the screen,

I need to do that when any ball (8 balls in total) collides with an invisible object (in this the “cross” should appear indicating a mistake, and continue in the scene).

Should I user “onCollision” function instead of “onTouch” function?

Sorry but this is the most confusing part for me, and is the only thing I couldn’t solve yet in order to finish it.

Thanks again!!!

Not exactly, I only need a cross that appears when a ball wronlgy collides with an object, and the cross should disappear after 2 seconds for example, blinking in the process.