• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android place_meeting not working

Erayd

Member
I'm not new to this, so when something like this just simply isn't working, I tend to lose my patience quickly. Truthfully, I'm probably just being a complete idiot, but here's the issue:

I am using place_meeting in conjunction with the device x and y position on an object to make it a button. So if the function returns true, then something happens, in this case going in to another room or starting the game. If I remove the place_meeting function, if I tap anywhere on screen the code runs smoothly without problem, but with the code, no matter where I touch the screen, nothing happens...

Code:
for(i = 0; i < 5; i++){
        if(device_mouse_check_button_pressed(i, mb_left)){
            if(place_meeting(device_mouse_x(i), device_mouse_y(i), obj_StartGame)){
                room_goto(GameRoom);
                state = "game";
            }
        }
}
 
Last edited:

obscene

Member
Well realize place_meeting takes to masks and sees if they collide.

So your code takes the object running this code, moves it to the mouse cursor position, and sees if it colldes with the obj_StartGame. The first question would be does the object running this code have a sprite/mask?
 

Erayd

Member
It does and it is the entire object or sprite. I've checked to make sure before I posted.

obj_StartGame is nothing special at all, just a visible object with a sprite placed in to the room.
 
S

Snail Man

Guest
Have you checked to make sure device_mouse_x and y are returning the correct values?
 

Erayd

Member
Just checked, since I'm using the whole room as my view, the x and y correlate to the x and y in the room. I cross checked the touch point with the position of the object SartGame and it definitely intersects it.
 
A

Aura

Guest
It does and it is the entire object or sprite. I've checked to make sure before I posted.
@obscene wasn't talking about obj_StartGame. He was talking about the object that you're running this code with. Generally place_meeting is used for checking collisions between two instances, given that both of them have valid collision masks. I guess you misunderstood him.

As for the solution, use position_meeting() instead as it does not depend on collision mask of the instance calling the code per se.
 
Top