This site requires JavaScript, please enable it in your browser!
Greenfoot back
AIMrOrange
AIMrOrange wrote ...

2014/4/15

SmoothMover in ScrollWorld

AIMrOrange AIMrOrange

2014/4/15

#
Hi, I got a problem with my Scenario "Heroes" and the movement precision combined with a scrolling world. Im using the ScrollWorld and ScrollActor by SPower and i also use SmoothMover. SmoothMover extends ScrollActor and ScrollActor extends Actor. Here my problem: Im using some movement precision with SmoothMover to make the spells actually fly to where you clicked. For example my Archer is shooting arrows:
                x = myinfo.getX();
                y = myinfo.getY();
                turnTowards(x,y);
                angle = Math.atan2(y-getExactY(),x - getExactX());
                move_x = Math.cos(angle) * speedArrow;
                move_y = Math.sin(angle) * speedArrow;
move_x and move_y are the parts the object hast to move to "simulate" this direct "line" to the target in every act(). Those two variables are the parameters for a new Arrow:
new Arrow(getRotation(), move_x, move_y);
In Arrow:
public void movement()
    {     setLocation(getExactX()+move_x,getExactY()+move_y);
    }
Thats the movement process as it would work in a normal world. But the problem is Im using a scrolling world, and there i dont want that object to move on the "camera", which is the "real" world, i want it to move on the "whole" world. For example i dont need to use the x and y coordinates, rather the globalX and globalY coordinates, but these are not double^^ Maybe it`s just a problem of reversed subclassing? (maybe ScrollActor should extend SmoothMover?) The result is that if I shoot an Arrow, everything works. But if I shoot it and move while it is flying, i can influence the movement with the "camera" because the arrow is using the x and y coordinates instead of globalX and globalY :/ I know it`s complex but maybe someone hast the patience to help me :) Thanks in advance, Max
AIMrOrange AIMrOrange

2014/4/15

#
ScrollActor and ScrollWorld by SPower can be found here: ScrollWorld
You need to login to post a reply.