GameMaker: Studio

GameMaker: Studio

통계 보기:
GameMaker: Studio > 일반 토론 > 제목 정보
Scorcher24 2012년 10월 2일 오후 9시 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?^^

< >
1-99개 댓글 표시
M.S.T.O.P. 2012년 10월 3일 오전 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 2012년 10월 3일 오전 6시 27분 
Yes, thats what I do. On Keypress I start moving it and and on key release I stop it.
Choam Nomsky 2012년 10월 3일 오전 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 2012년 10월 3일 오전 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.
Scorcher24님이 마지막으로 수정; 2012년 10월 3일 오전 6시 37분
Mizipzor 2012년 10월 3일 오전 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 2012년 10월 3일 오전 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.
Scorcher24님이 마지막으로 수정; 2012년 10월 3일 오전 7시 05분
M.S.T.O.P. 2012년 10월 3일 오후 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 2012년 10월 3일 오후 4시 48분 
Thanks mate :). I still think the world limits from Torque2D are cooler in that regard.
M.S.T.O.P. 2012년 10월 3일 오후 9시 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.
< >
1-99개 댓글 표시
페이지당 표시 개수: 15 30 50

GameMaker: Studio > 일반 토론 > 제목 정보
게시된 날짜: 2012년 10월 2일 오후 9시 59분
게시글: 9