Jump to content
Search Community

Soccer Simulation

sajjadkharrazi test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

i have an json file that contain 22 second of soccer match that contains data of 11 Home Player and 11 Away Player and 3 Referee and a Ball frame by frame.

for example: {"x":449,"y":358,"type":"H","jerseyNumber":"19"} ( type:H means Home)...

 

what is the best way to simulate this soccer match with pause and resume button in greensock.

 

sorry for my bad grammer  :|  :| 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

Please understand that we can't advise you on how to organize your data or set up your interaction logic. But in simple terms the best thing to do is just loop through your data and insert tweens into a timeline based on that data. Once all the animations are in a timeline it will be very easy to play and pause. 

Here is a rough demo:

 

http://codepen.io/GreenSock/pen/rxyeWo?editors=001

  • Like 2
Link to comment
Share on other sites

Dynamically adding and removing animations is going to require a lot more work. You're going to have to come up with your own logic to handle that. I think hiding and showing the players using autoAlpha is going to be the easiest way to do that. You could also create a separate timeline for each player, and then you can add or remove them from a main timeline. But you would still need to hide/show them using something like autoAlpha.

 

Here's an example of that. You can add and remove the third timeline whenever you want, and it will sync up with the other timelines. You could add your own callbacks to the timeline to do something like that.

 

See the Pen fa778e7c1622e6a85c9de438fdab4319?editors=001 by osublake (@osublake) on CodePen

  • Like 2
Link to comment
Share on other sites

I have to echo Blake's sentiment. Adding and removing players is certainly possible but will require a lot more logic that has very little to do with GSAP.

We have to keep our support focused on answering questions related to how the GSAP API functions. Unfortunately, it just isn't feasible for us to walk you through every difficult part of your project when it comes up. 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...