ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

Flash 3DX: Loading bar width does not increase

Open n0samu opened this issue 3 years ago • 1 comments

Describe the bug

In the first frame of Flash 3DX, there is a loading bar that is supposed to increase in width each time the frame runs: barre._width += 1; The next frame checks the width of the loading bar to decide whether to start the game:

if(barre._width < 315)
{
   gotoAndPlay(1);
}
else
{
   gotoAndPlay(3);
}

In Ruffle, the loading bar width never increases even after being incremented. Inserting trace(barre._width);, you'll see that the width always stays zero. So the game never starts.

Expected behavior

The loading bar width should gradually increase, like this: image

Affected platform

Desktop app

Operating system

Windows 10

Browser

No response

Additional information

No response

n0samu avatar Jul 15 '22 17:07 n0samu

Interesting... and funny because in fact the width is equal to 1 before it gets incremented. 😄

For instance, if you replace the whole code in frame 1 with this one:

trace("width: " + barre._width); // Flash Player: gradually incremented; Ruffle: 1 on the first call, then always 0
trace("height: " + barre._height); // always 0
barre._width = barre._width + 1;

The issue happens because the value of _height is 0. When the width is set and incremented, Ruffle calls DisplayObject::set_width: one of the calculations implies a division by zero (value / object_height) which ends up affecting the value of _width in an unexpected way (always 0 on the next steps).

It's possible to make the file work in Ruffle by using JPEXS: Shapes > DefineShape(29) > Raw edit > shapeBounds > Ymax (set a value greater than 0).

A few other observations:

  • If Xmin/Xmax and Ymin/Ymax are all 0, Flash Player won't increment the width.
  • In SWFv8+, it seems like the loading bar is no longer displayed but the width is still incremented, so the game can start.
  • Same rules apply when setting the height.

I have a branch that fixes the issue, as well as Megaman Zero (cc. #1966) where platforms seem to rely on this behavior. Not sure if that's the correct way to do it though.

Toad06 avatar Sep 10 '22 16:09 Toad06