Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Create movement like snake for iOS

$
0
0

Hello,

i have this function to create a snake like movement

 

stage.addEventListener(Event.ENTER_FRAME, function()

{

          head.x = mouseX;

  head.y = mouseY;

  tail.graphics.clear();

  tail.graphics.lineStyle(3, 0x005e00);

  tail.graphics.moveTo(head.x, head.y);

          nodes[0] = {x:head.x, y:head.y};

          for (i=1; i<tail_nodes - 1; i++)

          {

                    var rotation = Math.atan2(nodes[i].y - nodes[i - 1].y, nodes[i].x - nodes[i - 1].x);

                    var pos_x = nodes[i - 1].x + tail_len * Math.cos(rotation);

                    var pos_y = nodes[i - 1].y + tail_len * Math.sin(rotation);

                    nodes[i] = {x:pos_x, y:pos_y};

  tail.graphics.lineTo(pos_x, pos_y);

 

          }

});

 

this work perfectly on computer and browser but when i export the ipa file for testing on my ipad it works jerkily (seems like low framerate).

 

What is wrong? the event.Enter_Frame? any suggestion to create a similar effect?

 

Thanks,

Stefano


Viewing all articles
Browse latest Browse all 13519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>