RayCasts and how get distance from one object to other

Hello All,
can some one give me simple example how get distance between objects in Cocos2d-x 3.8.1.

I have spawn object at the bottom of screen, and in other place i will spawn other object at the top of screen, but i need be sure, are the top object leave some place between self and bottom object.
im come to Cocos2d-x from Unity3D, and in Unity i know how make this simple, but in Cocos2d-x, dont understand for a now ((

Please help if can!

Thank You!

From your description you only want to find the vertical distance between them - which you can calculate by subtracting the Y coordinates . Assuming you have the anchorpoint at (0.5,0.5) then if that distance is greater than (H1 + H2) / 2 (where H is the height of each sprite) then you have enough room.

You can do the same calculation for width too, if necessary (i.e. if the height ‘fails’ it may still be OK to position it if the width calculation ‘passes’)

The problem is in H1 and H2
I dont know how find spawned object at bottom in location on top.
That why i try understand how use raycast.
At the bottom, i spawn many objects, and at the top, some times less.
So, i cant get what H2 to take for calculations.

http://cocos2d-x.org/programmersguide/12/index.html#collision

scroll down for ray casts…

Perhaps you should try to explain better what you are trying to achieve?