A Shorter Snake

We had an interesting request about 2DIY sent to our support team last week.

A teacher asked:

Q: Can I make the snake have a shorter tail?

Whenever we get request like this, we do our best to find a solution and then publish these on our Support FAQ

Thanks to Daniel and Max for their combined soloution below

Q: Can I make the snake have a shorter tail?

A: Yes. In the Snake game, drag a sun object to the main area on-screen.

Edit the sun’s animation and choose “Adv”. Add the following ActionScript code.

for(n=6;n<=20;n++) {

   ob=eval(‘_root.p’ add n);

   ob._x=-20;

};

This will hide all except the first 5 segments of the snake’s tail.

 The first line provides a loop which cycles through from n=6 to n=20.

 The 2nd line sets which segment of the tail is being changed.

 The tail segments are named _root.p1, _root.p2 etc.

 The 3rd line sets the x position of the tail segment to a negative number, ie it is now off the screen.

To show this in action, I tested this on the Snake Screen today and below you can see a before and after shot:

This slideshow requires JavaScript.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s