Highlighted

Object return to original postion

New Here ,
Feb 01, 2020

Copy link to clipboard

Copied

Hi,

 

I have 6 pieces and 6 targets and i was wondering how do i make the pieces return to its orginal x and y axis when the piece is put into the wrong target.

The instance names for the pieces are:  piece1_mc piece 2_mc etc.

The target names are: target1_mc target2_mc etc.

TOPICS
Code

Views

245

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Object return to original postion

New Here ,
Feb 01, 2020

Copy link to clipboard

Copied

Hi,

 

I have 6 pieces and 6 targets and i was wondering how do i make the pieces return to its orginal x and y axis when the piece is put into the wrong target.

The instance names for the pieces are:  piece1_mc piece 2_mc etc.

The target names are: target1_mc target2_mc etc.

TOPICS
Code

Views

246

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 01, 2020 0
Adobe Community Professional ,
Feb 01, 2020

Copy link to clipboard

Copied

It would take a bit of time to write out all of the code, but here is the approach I would take:

 

Instead of placing the objects somewhere and then using some technique to know when they are in the right place, put them in their right place.

 

When you enter that screen, have each object store its own location, and programmatically move it to the start point. That might be a random location, or some other rule that lays them out neatly. Store that position too.

 

As the user drags the object, use Pythagoras to calculate the distance from the stored right place location.

 

If the distance is less than a certain tolerance, use a tween to move the object to the right place location, in a short amount of time.

 

If the distance is more than a certain tolerance, use a tween to move the object back to its stored start location, taking more time.

 

Both ActionScript and CreateJS have tween libraries built into them.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 01, 2020 0