Friday, 24 January 2020

Matter.Js scaling a sprite (related to other variables)

I'm using Matter.Js for an interactive animation. One feature I'm working on is to scale some of my bodies relative to their distance to the cursor. My issue is that I cannot seem to scale the sprite which covers these bodies. I tried scaling the bodies themselves but the sprite size did not actually change. So I figured I just needed to scale the sprite size. However I can't seem to get any configuration of Matter.Body.set() to make this change. Reading the source I'm not sure it is possible.

The documentation says: "Given a property and a value (or map of), sets the property(s) on the body, using the appropriate setter functions if they exist. Prefer to use the actual setter functions in performance critical situations."

I've tried:

Body.set(body, {
  render: {
    sprite: {
      texture: // url to sprite reset here incase of overwrite,
      xScale: scaleFactor,
      yScale: scaleFactor
    }
  }
});

This just seems to remove the sprite and any other render settings so I see nothing.

I've tried:

Body.set(body, 'render.sprite.xScale', scaleFactor);

This seems to do nothing at all and doesn't change the rendering.

Is it not possible to set the values of the sprite object at any moment other than the creation of the body? Or am I just targeting those values wrong in my function calls?



from Matter.Js scaling a sprite (related to other variables)

1 comment:

  1. The majority of foreign citizens who wish to enjoy a stay in the Russian Federation are required to apply for a eVisa for Russia, although the type of travel document required will depend on nationality, as well as the purpose and duration of the stay. Tourists intending to visit Russia for a short term stay can now apply for Russia eVisas, a much faster and more practical way to obtain a Russian travel authorization than the traditional Russian tourist visa.
    eVisas allow visitors to apply for their Russian visa entirely online in minutes, from.
    anywhere in the world. Passport copies, online application form, and other documents required for the visa can be submitted online. Currently, eVisas are available for specific Russian regions. In order to visit the regions of the Far East, Kaliningrad, and St Petersburg, it’s no longer necessary to present supporting documentation at a Russian embassy or consulate.
    E-visas can be of the following categories only: ordinary business visa,ordinary tourist visa, and ordinary humanitarian visa. If the purpose of your journey to the Russian Federation does not correspond to any of the above, you should apply for a traditional visa at a diplomatic mission or consular office of the Russian Federation

    ReplyDelete