【发布时间】:2021-03-24 08:25:49
【问题描述】:
我注意到当精灵变高时,夹具形状尺寸会适当增加。 相反,当尝试缩小精灵时,夹具形状尺寸会卡在原始精灵尺寸上。
非常感谢您的提示、帮助和支持。 为了显示这个故障,下面是 GML sn-ps:
在“创建”事件处理程序中:
// which controller
controllerID = 0;
// Configure the fixture
fix = physics_fixture_create();
physics_fixture_set_circle_shape(fix, sprite_width / 2);
physics_fixture_set_density(fix, .01);
physics_fixture_set_restitution(fix, 1.);
physics_fixture_set_friction(fix, 0.5);
//Bind the fixture to the current instance
//my_fix = physics_fixture_bind(fix, object_index);
my_fix = physics_fixture_bind(fix, id);
在“开始步骤”事件处理程序中:
var aButton = gamepad_button_check_pressed(controllerID, gp_face1 );
if ( aButton != 0)
{
image_xscale = image_xscale*.9;
image_yscale = image_xscale;
physics_remove_fixture(id, my_fix);
// Configure the fixture
physics_fixture_set_circle_shape(fix, sprite_width / 2);
//Bind the fixture to the current instance
my_fix = physics_fixture_bind(fix, id);
}
var bButton = gamepad_button_check_pressed(controllerID, gp_face2 );
if ( bButton != 0)
{
image_xscale = image_xscale*1.1;
image_yscale = image_xscale;
physics_remove_fixture(id, my_fix);
// Configure the fixture
physics_fixture_set_circle_shape(fix, sprite_width / 2);
//Bind the fixture to the current instance
my_fix = physics_fixture_bind(fix, id);
}
当精灵收缩时,很容易检查夹具形状尺寸是否遵循精灵尺寸:只需将physics_world_draw_debug(phy_debug_render_shapes)放入“绘图事件”处理程序中。 我们可以看到,fixture 的形状尺寸随着 sprite 的扩展而增长,但当 sprite 尺寸回到 sprite 原始尺寸时保持不变。
它看起来真的像物理引擎中的一个错误......
感谢您的 cmets。
干杯
西尔万
【问题讨论】: