I would like to render 4 similar ropes in my game that are equidistant on a landscape mode display.

How can I proceed? My screen is 1920*1080, at 420 dpi.

Is there any way that I could link the ropes coordinates with pixels or is there another way?

  • \$\begingroup\$ What exactly do you mean by "equidistantly" here? \$\endgroup\$ – htmlcoderexe Apr 6 '20 at 14:36
  • \$\begingroup\$ Unrelated comment - but good job on posting your queries as separate questions \$\endgroup\$ – Natalo77 Apr 6 '20 at 15:56

I think your screen size will likely vary between phones.

You should use a method to access the screensize.

Probably subtract a buffer (say 200 pixels) from each side of the screen size (e.g. 1920 - 2*200)

Divide the remainder by 5, as you want 4 ropes (so 5 gaps between them)

B = Buffer , G = Gap, | = Rope

B G | G | G | G | G B

Use a 'Screen Space to World Space' transformation to transform co-ordinates for the rope positions into world space coordinates at which they can be placed.

Rope n Position = BufferSize + n*GapSize

  • \$\begingroup\$ Please can you detail how to transfor co ordinates into world space. I only know the x,y coordinate system that starts from the bottom left of the screen.Am I mistaken? \$\endgroup\$ – aqw Apr 6 '20 at 16:46
  • \$\begingroup\$ I found a drawable.setBounds(x,y,a,b) wherd I can set the limits for my renderd image. Is it useful? \$\endgroup\$ – aqw Apr 6 '20 at 16:53
  • \$\begingroup\$ I am not experienced in Java android studio - specific technical advice is something I can't give - I can only help you in terms of suggesting an approach that you might take, as I have done. \$\endgroup\$ – Natalo77 Apr 7 '20 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.