• 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!

Legacy GM Fade One(Not All) Particular Physics Fixture Sprite?

J

JeZxLee

Guest
Hi,

Does anyone know if it is possible to change the alpha transparency of just one Physics fixture sprite?

I have the following code to draw all Physic fixtures in my game:
Code:
with (SelectRedObject)  DrawSpriteOntoScreen(SelectRedSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
with (SelectOrangeObject)  DrawSpriteOntoScreen(SelectOrangeSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
with (SelectYellowObject)  DrawSpriteOntoScreen(SelectYellowSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
with (SelectGreenObject)  DrawSpriteOntoScreen(SelectGreenSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
with (SelectBlueObject)  DrawSpriteOntoScreen(SelectBlueSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
with (SelectPurpleObject)  DrawSpriteOntoScreen(SelectPurpleSmall, 0, phy_position_x, phy_position_y, 1, 1, 0, 255, 255, 255, 1);
The last "1" in the function "DrawSpriteOntoScreen()" is the alpha transparency.
I just don't know how to choose a single Physics fixture (not all).

Any help would be appreciated, thanks!
 
J

JeZxLee

Guest
Hi,

This is my Physics fixtures initialization code:
Code:
var inst;
physics_fixture_set_circle_shape(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], 15);
physics_fixture_set_density(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], 1.0);
if      (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 1)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectRedObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 2)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectOrangeObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 3)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectYellowObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 4)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectGreenObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 5)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectBlueObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 6)  inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectPurpleObject);
physics_fixture_set_collision_group(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], 1);
global.ColoredBallMyFixtureIndex[global.NumberOfColoredBalls] = physics_fixture_bind(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], inst);
Hope someone can help, thanks!
 
J

JeZxLee

Guest
Hi,

We got it working, thanks!

We destroy the instance and setup a temporary sprite with fading.
Code:
with (SelectRedObject)
{
    if ( phy_speed_y == 0 && phy_position_y > (global.SelectorLiquidLevel-50) )
    {
        global.SelectorLiquidLevelAdd+=20;
       
        for (var index = 0; index < 10; index++)
        {
            if (global.MeltLittleBallColor[index] == 0)
            {
                global.MeltLittleBallColor[index] = 1;
                global.MeltLittleBallScreenX[index] = phy_position_x;
                global.MeltLittleBallScreenY[index] = phy_position_y;
                global.MeltLittleBallScale[index] = 1;
               
                index = 999;
            }
        }
       
        instance_destroy();
    }
}
 
Top