Drag-Drop / setting frame when dragging left-right


Attached Files

The following files have been attached to this tutorial:



Download now 259.51 KB


2,366 visits, 3,792 views



This tutorial hasn't been translated.


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.

Hi everybody,

Recently, I asked a question on the forum basically asking:

When using drag-drop behavior how do I change frames of the sprite?

(because it's not a simple press right left button event )

I was only enabling left and right movement and wanted to,

for example.,

if idle (dropped), set to frame 0

if dragging left, set frame to 1

If dragging right, set frame to 2

here is a demo:

Click Here for Demo

I got a response from @Zaoeyo, (thanks you BTW) who said ..


Add a globe variable(maybe named OldMouseX) to know where is your mouseX when you start

When you are dragging the object , using the OldMouseX subtract the present mouseX ,to get the direction of your moving. If it is positive ,you are moving to right, if negative , is left.

I have uploaded the capx ,

This 'game' does NOT require plugins.

and here is a view of the event sheet



Download now 259.51 KB

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