Hi, I'm trying to set the rotation of my "orbes" according to the position of an "aimer"
The aimer is in the top right corner and my orbes are in the center of my world
Here's my code:
I tried many times and found out that the angle is either 0 (or even -45° if dy is higher than dx)
I already asked the same question some days ago and tried the answer you game me but it doesn't want to work in the current code... please help me^^
public void shoot() { if(counter == 280) { Aimer aimer = new Aimer(); getWorld().addObject(aimer, 600, 100); } if(counter == 290) { Actor aimer = (Actor)getWorld().getObjects(Aimer.class).get(0); int xAimer = aimer.getX(); int yAimer = aimer.getY(); List<Orbe> orbes = getWorld().getObjects(Orbe.class); int length = orbes.size(); if(length>=1) { for(Orbe orbe : orbes) { int xOrbe = orbe.getX(); int yOrbe = orbe.getY(); int dx = xAimer-xOrbe; int dy = yAimer-yOrbe; int angle = (int)Math.toDegrees(Math.atan(dy/dx)); orbe.setRotation(180-angle); readyToGo = true; } } } }