The Magnet Effect

1

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

3,128 visits, 5,225 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 16 Sep, 2013. Last updated 19 Feb, 2019

Hi, In this Tutorial we are going to learn how to make the Magnet Effect, First you need three object:

1) Sprite: Magnet.

2) Sprite: Screws.

3) Button: reset

First you must have two sprites: Magnet and screws, You'll need to make your own graphics.

Second you must create a button named reset for resitting layout.

After you got the sprites you must add the dragndrop behavior to the Magnet, and three behaviors for the screws: custom movement, Line of sight, and Pin behavior. Also you must add instance variables for screws called On and make it Zero., and make the line of sight range 150.

Now, For the Events, Lets Start To the Graphic Effects, add (EveyTick) event, and add condition for screws : Set angle Towards position (Magnet.X & Magnet.Y).

Second Event: For Screws, when they have Line Of Sight to Magnet, and if there instance variable (On) is Zero. Add Condition: Custom Movement Accelerate 5000 px/sc toward (Magnet.X & Magnet.Y)

Third Event: Add Event when the screw collide with Magnet. Add Condition: Set Instance Variable On to 1; Stop Custom Movement; Pin Screw to Magnet By Position and Angle.

Fourth Event: Add event when Reset button is clicked, Add Condition: Reset Layout.

If you want to test it or See its demo, The .capx file is attached.

.CAPX
  • 0 Comments

Want to leave a comment? Login or Register an account!