Chris Smith
Member
What I am trying to do is use groups of the same object, for clarity I call the object obj_alphablock, to create a similar effect to what you see in newer mario sidescrollers, where you walk through a part of the wall and the wall goes transparent.
Essentially I want a collision between the player and any single block in a group, to make the entire group's image_alpha drop, and then when the player is no longer touching any of the blocks, their alpha goes back to 1.
I have it kind of working. But I have no idea what is causing it's strange behavior. If and entire column is touched by the player, their alpha wont' return to 1, and other similar behaviors.
How would you do this?
I've included a video showing what is happening. And my code is below.
Essentially I want a collision between the player and any single block in a group, to make the entire group's image_alpha drop, and then when the player is no longer touching any of the blocks, their alpha goes back to 1.
I have it kind of working. But I have no idea what is causing it's strange behavior. If and entire column is touched by the player, their alpha wont' return to 1, and other similar behaviors.
How would you do this?
I've included a video showing what is happening. And my code is below.
Code:
if touched = true image_alpha = 0.2
if touched = false image_alpha = 1
instright = instance_place(x+1,y,obj_alphablock) //check to the right/left/top/bottom
instleft = instance_place(x-1,y,obj_alphablock) //to see if there is another alphablock int he group
instdown = instance_place(x,y+1,obj_alphablock)
instup = instance_place(x,y-1,obj_alphablock)
if place_meeting(x,y,obj_player) //if the player is behind the block, lower the alpha
{
touched = true
}
else if !place_meeting(x,y,obj_player) //if the player is not behind the block, check to see if he is behind another block in the group
{
touched = false //if player is not touching, set alpha to 1
if instright != noone //if there is a block to the right
{
if instright.touched = true //and if it's 'touched' variable is true, make mine true too
{
touched = true
}
else touched = false
}
if instleft != noone
{
if instleft.touched = true
{
touched = true
}
else touched = false
}
if instdown != noone
{
if instdown.touched = true
{
touched = true
}
else touched = false
}
if instup != noone
{
if instup.touched = true
{
touched = true
}
else touched = false
}
}