Forum Discussion
Is there a way/javascript code to store and repeat a position an object?
Hi all,
I am designing a game in which the learner needs to drag a group of objects to an area. After moving to the next level/slide I need to keep all the changes the learner made as is.
Now, two challenges are here:
First, getting the positions of the objects.
Second, moving the objects to the latest positions.
So .. any help here is highly appreciated.
Thank you ..
4 Replies
- MathNotermans-9Community Member
Both is possible. Getting the position differs quite a bit in the Classic Player and the Modern Player.Also using either Storyline3 or Storyline360 makes a difference. But it is possible. Your best bet is SL360 because it has GSAP included, so you can get all done with that.
- AhmedGendyaCommunity Member
Hi Math,
Thanks for your reply.
How can I get the dynamic position of an object?
- MathNotermans-9Community Member
Best to share a sample to work from...then i can show it properly. If using SL360 you can use GSAP's get functionality.
Here some help on GSAP...
A clear explanation of the position parameter...
https://greensock.com/blog/learning/position-parameter/And then you offcourse need to get the current dynamic position..
https://greensock.com/docs/v3/GSAP/gsap.getProperty()
So with code like this you can get the actual x and y of an element.var myElement = document.querySelector("[data-acc-text='someAccName']");var elXPos = gsap.getProperty(myElement, "x", "px");var elYPos = gsap.getProperty(myElement, "y", "px");console.log("x: "+elXPos+" | y: "+elYPos);Where 'someAccName' is the accessibility name of your element.
Kind regards,
Math- AhmedGendyaCommunity Member
Thank you so much Math for sharing this with me ..
Best,
Related Content
- 12 months ago