Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using StateMachines with StateMachineNames #315

Open
ecenazelverdi opened this issue May 24, 2023 · 0 comments
Open

Using StateMachines with StateMachineNames #315

ecenazelverdi opened this issue May 24, 2023 · 0 comments
Labels

Comments

@ecenazelverdi
Copy link

Hello, I was trying to create a dynamic rive where I can get State Machine Name without looking at it in Rive Editor but I can't find a way to use it with stateMachines. I searched documents, I looked examples but I couldn't see any example doing it so I fonder if there is a way or not. If there isn't a way to use it with stateMachines with stateMachineNames, it would be great to create one! This is what I tried to do so far (I'm using Vue2):

mounted() {
    let rive = new Rive({
      src: 'https://public.rive.app/community/runtime-files/4075-8441-blobby-button.riv',
      canvas: this.$el.children[0],
      autoplay: true,
      layout: new Layout({
        fit: Fit.Contain,
        alignment: Alignment.Center,
      }),
      onLoad: () => {
        rive.resizeDrawingSurfaceToCanvas();
        let stateMachine = {
          artboard: rive.artboard,
          inputs: rive.stateMachineInputs(`${rive.stateMachineNames[0]}`), //This do not work
          playing: true,
          name: rive.stateMachineNames[0],
        };
        rive.animator.stateMachines.push(stateMachine); //This wont work
      },
    });
  },

I also tried this :

mounted() {
    let rive = new Rive({
      src: 'https://public.rive.app/community/runtime-files/4075-8441-blobby-button.riv',
      canvas: this.$el.children[0],
      autoplay: true,
      layout: new Layout({
        fit: Fit.Contain,
        alignment: Alignment.Center,
      }),
      stateMachines: rive.stateMachineNames,
      onLoad: () => {
        rive.resizeDrawingSurfaceToCanvas();     
       },
    });
  },

Am I doing something wrong or is there currently no way to do that. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant