• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to make something move in opposite direction the mouse is moving?

New Here ,
Mar 09, 2016 Mar 09, 2016

Copy link to clipboard

Copied

Hello dear community.

I've seen on Sarif Industries‌ some cool background animations. Especially the background animation where everyting moves in opposite direction the mouse is moving.

So I did want to try doing this kind of animation too. But I don't know how I can do this nor do I know how this kind of animation is called.

I can't code but I do understand programming languages.

*For everyone who doesn't want to go on the linked website*

As said everything is moving in opposite direction the mouse is moving but it seems like the objects only moves in a determinated area and the objects are moving slower as the mouse is moving.

Thank you in advance and have a nice day

TOPICS
ActionScript

Views

717

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
community guidelines

correct answers 1 Correct answer

Explorer , Mar 09, 2016 Mar 09, 2016

stage.addEventListener(onMouseMove, MouseEvent.MOUSE_MOVE);

private function onMouseMove($e:MouseEvent):void

{

     _myBG.x = -stage.mouseX;

     _myBG.y = -stage.mouseY;

}

You have everything you need in there.

Just tweak the operations to get the desired effect...

Add " * 0.5" to make it move more slowly for instance.

Votes

Translate

Translate
Explorer ,
Mar 09, 2016 Mar 09, 2016

Copy link to clipboard

Copied

stage.addEventListener(onMouseMove, MouseEvent.MOUSE_MOVE);

private function onMouseMove($e:MouseEvent):void

{

     _myBG.x = -stage.mouseX;

     _myBG.y = -stage.mouseY;

}

You have everything you need in there.

Just tweak the operations to get the desired effect...

Add " * 0.5" to make it move more slowly for instance.

Votes

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
community guidelines
New Here ,
Mar 10, 2016 Mar 10, 2016

Copy link to clipboard

Copied

Thanks for your help

Votes

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
community guidelines
Engaged ,
Mar 10, 2016 Mar 10, 2016

Copy link to clipboard

Copied

That's a really nice effect.

If you have time, could you please explain how you implement this.

In its simplest form how would I apply this to an object on my stage. I assume it is an action that is applied to a frame/s, but how do I do that.

Keen to learn.

Thanks

EDIT: I've just noticed this is in the Actionscript forum - is it possible to achieve this effect when using HTML5 Canvas?

Votes

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
community guidelines
New Here ,
Mar 10, 2016 Mar 10, 2016

Copy link to clipboard

Copied

It probably should work for HTML5 Canvas too and I think the HTML5 code isn't much different than the actionscript code above.

But I'm no programmer so I can't really help you with coding.

Votes

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
community guidelines
Engaged ,
Mar 10, 2016 Mar 10, 2016

Copy link to clipboard

Copied

LATEST

Thanks Blublok.

I'll persevere with it and see if I can get it working.

Votes

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
community guidelines