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

2014/4/12

Coding a ramp?

1
2
danpost danpost

2014/5/7

#
I have seen many strange things happen when trying to program a scrolling system. I am not sure that this is one of them; and even it if was, I would be able to say for sure what is causing it. It could be something as simple as what 'collideGroundY-y' evaluates to and the movement caused by line 26 of the MegaMan X animation code. It could be something like a wrong condition or value somewhere that would almost be impossible to find.
Entity1037 Entity1037

2014/5/7

#
I've been calculating on the computer calculator, but I can't seem to find any result for what is happening. What seems to happen is that the character moves down at around the same speed the screen was moving when X hit the ground. You can easily recreate the problem on the scenario. I added a ground detection visual that shows the region the ground is being detected in. The problem is that... well everything works normally, but then X just decides to move down for no reason until the screen stops scrolling with absolutely no warning, and no obvious reason can be seen for the start of this movement. The scenario is here: http://www.greenfoot.org/scenarios/9829 If you play the scenario act by act, you can obviously see the code work properly, but then X just moves down for no reason. The problem, I've noticed, is ONLY happening to X. If I omit lines 24, 25, and 26 of the X code I provided, the problem completely goes away. However, that code really can't be omitted permanently, due to it's function being aligning X to the ground and adjusting his hit detection so that X can dash and whatnot without floating in the air, and without having animations that don't look right. So do you have any ideas? I did the calculations on the computer calculator (as I mentioned above), but I can't seem to find any odd calculation. I think it must be from an interaction between the scrolling engine and the repositioning in X's code. Perhaps there's some kind of lag that's causing it?
Entity1037 Entity1037

2014/5/14

#
I have pinpointed the problem. The issue only happens when the player's code setsLocation more than once per cycle. It appears that it does has something to do with the interaction of the player setLocation from the player itself with the setLocation of the scrolling engine. I can, however, work around this issue by adjusting the height of the player's image and just moving that instead of the player (which I probably should of done in the first place, honestly).
You need to login to post a reply.
1
2