GameMaker: Studio

GameMaker: Studio

Ver estatísticas:
GameMaker: Studio > Discussões gerais > Detalhes do tópico
Scorcher24 2/out/2012 às 21:59
Sprites continue to move after collision
Difficult to explain.

I have a playersprite that consists out of 3 sprites, arranged next to each other. All 3 Sprites are controlled by the middle sprite that handles the movement and moves the sprites left and right with it. When either the left sprite or the right sprite hit the level boundary, which is represented by an object called objWallSide, all 3 sprites are supposed to stop immediatly.

But they don't. The middle sprite continues to move until the middle sprite hits objWallSide, pushing the left and the right sprites on the same position where the middle one is. And yes, I added a movement modifier for all sprites in the collision routine.

Anyone got any hints?^^

< >
Exibindo comentários 19 de 9
M.S.T.O.P. 3/out/2012 às 1:49 
How are you controling the movements? Using keyboard events? If so, are you setting the speed and direction of each object within those keyboard events?
Scorcher24 3/out/2012 às 6:27 
Yes, thats what I do. On Keypress I start moving it and and on key release I stop it.
λ 3/out/2012 às 6:30 
I never used this software, but is there a way to get the code of your game? If so, you should probably post it. Or post anything that is describing the relationships between your objects and your logic. Some downsides of Game Maker Studios are becoming apparent...
Scorcher24 3/out/2012 às 6:35 
Well there is no code, otherwise I would post some :D.
I know programming and that's not my first prototype, but yeah, thats a downside of it :).
But maybe that screenshot hels:
It contains the visual scripts for objPlayerMiddle Keypress Event and the collision code of objWallSides.

The "Start moving in a direction" command in the Keypress Event is moving all 3 sprites into one direction when the key is pressed, the same command with parameter 0 is issued when the key is released or when either the left or the right sprite hit the wall.
Última edição por Scorcher24; 3/out/2012 às 6:37
Mizipzor 3/out/2012 às 6:52 
If a collision stops the sprite and a key press moves the sprite what happens if you hold down the key while the collision occurs? Just a guess but I think the key press takes precedence in your case. Maybe add a check after the key press but before you move that makes sure its valid for it to start moving.
Scorcher24 3/out/2012 às 6:54 
I tried that, it might prevent the sprite from moving at all after I touched the wall, since I did not find a "collision over" event. Also, even with setting a variable, this happened. Is there no way to just set some level boundaries where the player cannot move beyond? You can do that in Torque2D which I own.
Última edição por Scorcher24; 3/out/2012 às 7:05
M.S.T.O.P. 3/out/2012 às 12:48 
I think I got it. As mizipzor said, you need to check if there isn't a wall in the way before you move. You can do that by using a "Check Object" action in the keyboard events.

This code gets the desired results for me:
Scorcher24 3/out/2012 às 16:48 
Thanks mate :). I still think the world limits from Torque2D are cooler in that regard.
M.S.T.O.P. 3/out/2012 às 21:10 
There is an event called "Intersect Boundary" that triggers whenever an object intersects the boundaries of a room. You could tell the objects to stop in that event. Functionally, I think it's same as what you're doing, except you don't have to manually wall off every room you create.
< >
Exibindo comentários 19 de 9
Por página: 15 30 50

GameMaker: Studio > Discussões gerais > Detalhes do tópico
Publicado em: 2/out/2012 às 21:59
Mensagens: 9