How can i move Sprites Like this?

0 favourites
  • 15 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • I have a Sprite with four Frames and I want to rotate this something like this

  • Hmm, that is an interesting question...

    You might be able to do something like by having the image point at the very center of the circle (of circles), then rotating while using a horizontal sine.

    Getting them in sync with this method would seem like a nightmare (if it desyncs)

    Edit: Sorry misunderstood. But not I'm not sure what you have, and what you want... You have a current animation?

  • It looks like the four sprites are moving in a diamond shape.

    Add an instance variable to the sprite and call it “t”. Set each of the four instances to 0,1,2 and 3.

    Then create another sprite called “node” and place four instances in a diamond shape.

    Then in events you can do this:

    Every tick:

    — sprite: add dt to t

    — sprite: set x to lerp(node(int(self.t)).x, node(int(self.t)+1).x, self.t-int(self.t))

    — sprite: set y to lerp(node(int(self.t)).y, node(int(self.t)+1).y, self.t-int(self.t))

  • You can create a square sprite with 2 behaviors: rotate and sine (size).

    Then set the position of circles to the 4 corners.

    c3p file

  • You can create a square sprite with 2 behaviors: rotate and sine (size).

    Then set the position of circles to the 4 corners.

    c3p file

    Bro, that's incredible!

    Thanks for the info.

  • It looks like the four sprites are moving in a diamond shape.

    Add an instance variable to the sprite and call it “t”. Set each of the four instances to 0,1,2 and 3.

    Then create another sprite called “node” and place four instances in a diamond shape.

    Then in events you can do this:

    Every tick:

    — sprite: add dt to t

    — sprite: set x to lerp(node(int(self.t)).x, node(int(self.t)+1).x, self.t-int(self.t))

    — sprite: set y to lerp(node(int(self.t)).y, node(int(self.t)+1).y, self.t-int(self.t))

    Yes They are moving in a diamond shape

    I did same as you said but nothing worked.

  • Just tried the C3p file and works perfectly.

  • Just tried the C3p file and works perfectly.

    May be because I didn't understand what he exactly says and because I am not good in English. I have doubt about below lines which i didn't understand. Can you exaplain these in simple.

    Add an instance variable to the sprite and call it “t”. Set each of the four instances to 0,1,2 and 3. Then create another sprite called “node” and place four instances in a diamond shape

  • If you open his C3p check the instance variables.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you open his C3p check the instance variables.

    I was talking about R0J0hound 's Suggestion.

  • It very well may not work since I haven’t tested it.

  • link to c3p

  • Thanks

    Thank you so much el3um4s to make c3p file

    and much much thanks to R0J0hound

    He has always a solution for any kind of problem.

    Thanks again.

  • Hi R0J0hound

    can you please explain what is actually happening in this event. Actually This is working but I'm not getting what actually happening.

    — sprite: set x to lerp(node(int(self.t)).x, node(int(self.t)+1).x, self.t-int(self.t))

    — sprite: set y to lerp(node(int(self.t)).y, node(int(self.t)+1).y, self.t-int(self.t))

  • You can access specific objects by their iid in expressions like so:

    Sprite(0).x gets the first sprite’s x

    Sprite(1).x gets the x from the second sprite.

    So say you have four instances you can access their x’s with

    Sprite(0).x

    Sprite(1).x

    Sprite(2).x

    Sprite(3).x

    Not only that but the number wraps around so you can use 4 to access the first one again.

    So what that expression is doing is it uses the variable t to specify a location between instances.

    For example with a t of 1.33

    It takes instance 1 and instance 2 and uses lerp to find the location a third of the way from instance 1 and 2.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)