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

2018/12/26

Game Creation: Directional Idle, Shooting and Jumping.

4
5
6
7
8
9
10
danpost danpost

2018/12/28

#
Unlimited wrote...
No i know, i dont have them in the code. I just though the way its handeled here would be helpful. Cause without the -3s and -2s the same thing happened with this method.
That was like the last thing tried before having you upload it, where "That sadly Didnt Work".
Unlimited Unlimited

2018/12/28

#
I see, so what now?
danpost danpost

2018/12/28

#
Unlimited wrote...
I see, so what now?
We do it again -- but this time, we do it right. In the moveVertically method, insert the '+1' after the '/2' as before. This time, place parenthesis around everything after 'vDir*'. Should look like this:
setLocation(getX(), actor.getY()-vDir*((actor.getImage().getHeight()+getImage().getHeight())/2+1));
Unlimited Unlimited

2018/12/28

#
Ok the character is not teleporting around when touching the platform but bouncing around above it. Only teleporting when touching the border.
danpost danpost

2018/12/28

#
Unlimited wrote...
Ok the character is not teleporting around when touching the platform but bouncing around above it. Only teleporting when touching the border.
The problem is that the images in the animation sets for the actor have different widths. This allows the actor to get close to an object when a small width image is used, which causes a collision with the object when the image is changed to a larger width. So, you have collision due to animation. Obviously, if all your images for the actor were the same width and height, you would not have the problem; so making them so is one way to avoid this issue. The other way would be some complex coding to deal with the collision after every image change -- not something you would want to do.
Unlimited Unlimited

2018/12/28

#
But i also want to have a ducking animation, so given that even if i make every of my animations the same width and same high i will have the problem that the ducking will not work and my character will still just around above the platform rather then slightly inside how its supposed to. Is there a way to make the animations and the movement seperate so they dont interfere?
Unlimited Unlimited

2018/12/28

#
or Just telling the plattform how big the character sprite is supposed to be rather then to use the get image method. That way even if the animation changes so long its within the area we put it it should be fine right? Is that possible?
danpost danpost

2018/12/28

#
Unlimited wrote...
or Just telling the plattform how big the character sprite is supposed to be rather then to use the get image method. That way even if the animation changes so long its within the area we put it it should be fine right? Is that possible?
What you can do is find the largest width and the largest height of all the images and draw each image on a new frame with those dimensions. Draw all images as low as possible without loss of image. Draw left moving images toward the left and right moving images toward the right and standing images in the middle horizontally.
Unlimited Unlimited

2018/12/28

#
What do you mean draw? The Character is not drawn. (also its not mine) Do you mean like all of them in the same size? Though that cannot be it. Since all of my animations are cutouts as in all animations that are in one direction are the same size. Meaning All Walking sprites are the same size and all standing animations are the same size. It cant be a size problem since the only possible difference could be in between animations like pressing left then right but the teleportation happens when i only press one direction and only when touching the objects.
Unlimited Unlimited

2018/12/28

#
Not sure if i explained that understandably.
Unlimited Unlimited

2018/12/28

#
So ive played around a bit and it seems that something is wrong with these lines
Actor actor = getOneIntersectingObject(Collider.class);
        if (actor != null) setLocation(actor.getX()-dir*(actor.getImage().getWidth()+getImage().getWidth())/2, getY());
as other ground check methods work just fine with the animations. something does not work about these setlocation methods.
danpost danpost

2018/12/28

#
Unlimited wrote...
Not sure if i explained that understandably.
I understand what you are trying to say. However, even in the same animation set, there are small differences in the size of the images. Obviously, there are major differences between sets, which makes teleporting happen regularly like between standing and moving toward an object after first stopping at that object.
So ive played around a bit and it seems that something is wrong with these lines << Code Omitted >> as other ground check methods work just fine with the animations. something does not work about these setlocation methods.
Other than the missing '+1' and parentheses in the line you gave, it should be fine. Maybe a slight position adjustment is needed when the animation set changes and a collision is found.
Unlimited Unlimited

2018/12/28

#
Just, what can we do so it works? Because if i understand right even if remake all my animations it doesnt help me. Do you maybe have a different idea for collision? Because i still need my jump working, my shooting working and most importantly my platforms working. You are saying it does not work with this method then maybe we can find a different way because no matter what we do i cannot give the program like that to my teacher.
Unlimited Unlimited

2018/12/28

#
If there is no quick solution then lets go over to the jumping and landing animation. Is that ok?
Unlimited Unlimited

2018/12/29

#
Should i post how the code looks currently?
There are more replies on the next page.
4
5
6
7
8
9
10