Help with sprite and jump through platform!

B

Brian Le

Guest
Hi guys, I got a few problems with my character's sprite and the platform. First of all, the platform can be jumped through by the player when it is under the platform. Secondly, if the player has stood on the platform, the platform's mask index changed into 1.
Also, note that when I first code the game, I used a square-shaped character. When I pressed the Up key, it stood nicely on the platform. However, when I changed the sprite into the my desired images, I noticed that the player stood at a position of about 6 pixels from the platform. The player's sprite is 64x64, and the origin is center. The platform has an origin of 32x16, the origin is 0,0. I have posted some images for better illustration:
upload_2017-7-27_12-32-56.png
Also, here is the platform code
Code:
//Create Event:
sprite_index = -1;
//Step Event
if (instance_exists(obj_player)) {
    if (round(obj_player.y + obj_player.sprite_height/2) > y + 1 || obj_combokey_controller.force_down) {
        mask_index = -1;
    }
    else {
        mask_index = 1;
    }
}
//Draw Event
draw_sprite(spr_platform,-1,x,y);
Please help me with this, thanks in advanced
 
B

Brian Le

Guest
I suggest that you re-implement the jump through platforms. Read this thread:
https://forum.yoyogames.com/index.p...ed-on-how-to-get-a-jump-through-platform.8133
Yeah, I have read the solution, however I didn't understand. I really want to control the platform in another object, in order for future use. I also made combo key for jumping down the platform, as a result, it should be useful if you told me to separate the platform into another object, or maybe just explain the code for me, and thanks in advanced for that!
 
Top