Drag-Drop / setting frame when dragging left-right

3

Attached Files

The following files have been attached to this tutorial:

.capx

zzz-drag-drop-set-frame.capx

Download now 259.51 KB

Stats

2,980 visits, 4,638 views

Tools

Translations

This tutorial hasn't been translated.

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 14 Dec, 2013. Last updated 19 Feb, 2019

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 ..

Solution:

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

.CAPX

zzz-drag-drop-set-frame.capx

Download now 259.51 KB
  • 0 Comments

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