The 2DIY script archive

A resource containing Actionscript examples for 2Simples 2DIY software.

  • ActionScript
  • Animation Script
  • Collision Script
  • Start Button Script
  • Examples
  • Ideas
  • Help/Videos
  • Discuss

Make a monster orbit around a collectable item

In a platform activity, you can make a monster circle around a collectable item, making it difficult for a character to collect the item.

Within a platform activity select the top "apple" and then select a "monster" and place it on the apple. Right click on the monster, then click on the green rotation arrow below the image to view the animation options that are attached to the monster. Click on the red fish (for animation settings) and click on the "adv" option. in the script box that appears, enter the following code;

var angle = Math.atan2(this._y - _root.s13._y, this._x - _root.s13._x) + 0.05; 
this._x = _root.s13._x + Math.cos(angle)*100;
this._y = _root.s13._y + Math.sin(angle)*100;

Explanation: You need to understand trigonometry for this one! The first step works out the angle between the 2 objects by taking the arctan of the difference in y over the difference in x. The 0.05 adds slightly to the angle which results in the orbit effect. The next two lines calculate the x and y position of  the monster by starting off from the apple's position and taking the cos or sin of the angle, multiplied by the radius of the orbiting circle (in this case 100).

View example, Download Orbiting_monster

Posted by Xannov in Animation Actionscript | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

Make a monster that is ALMOST impossible to pass

In a platform activity, you can make a monster almost mimic the character along the x (horizontal) axis and make it almost impossible for a character to get past.

Within a platform activity select a "monster" and place it either above or below your character. Right click on it then click on the green rotation arrow below the image to view the animation options that are attached to the monster. Click on the red fish (for animation settings) and click on the "adv" option. in the script box that appears, enter the following code;

this._x +=  (_root.player._x - this._x) / 16 ;

What's happens is that the monster's x co-ordinate changes so it gets closer and closer to the x co-ordinate of the player, however it only moves a fraction of the distance at a time so it gives the player a chance to get through!

View example; Download Almost_impassable

Posted by Xannov in Animation Actionscript | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

Make a monster that is impossible to pass

In a platform activity, you can make a monster mimic the character along the x (horizontal) axis and make it impossible for a character to get past.

Within a platform activity select a "monster" and place it either above or below your character. Right click on it then click on the green rotation arrow below the image to view the animation options that are attached to the monster. Click on the red fish (for animation settings) and click on the "adv" option. in the script box that appears, enter the following code;

this._x=_root.player._x;

Now everytime you move to the left or right, the monster will move exactly the same distance either above or below you.

View example; Download Impassable

Posted by Xannov in Animation Actionscript | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

Increase character size through your score

When editing a journey or platform activity you can choose an "animation" element (the sun) to cause an effect that increases the character size depending on your score.

Within the activity select a "sun", right click on it and change the image to a background, decoration image. Once you are happy with your image, click on the green rotation arrow below the image to view the animation options that are attached to this image. Click on the red fish (for animation settings) and click on the "adv" option. in the script box that appears, enter the following code;

_root.player._xscale = 100+_root.sc*20;
_root.player._yscale=_root.player._xscale;

Note: In a platform activity, use "player", but in a journey activity change "player" to "car".

View example; Download Character_grows

Posted by Xannov in Animation Actionscript | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

« Previous Articles

Search

Recent Posts

  • 2DIY with Gifted and Talented groups
  • Making characters fly (and other effects)
  • High Lawn Primary Games
  • Creative Learning
  • Gallons of Games
  • Games Pod Creations
  • Kensington Avenue Primary 'Games Pod'
  • Actionscript Tutorial No.8
  • ActionScript Tutorial No.7
  • ActionScript Tutorial No.6

Recent Comments

  • Xannov on Discuss
  • Angela Canas on Discuss
  • Xannov on Discuss
  • Angela Canas on Discuss
  • Xannov on Discuss
  • Ali on Discuss
  • Xannov on Discuss
  • Max Wainewright on Discuss

Archives

  • June 2011
  • May 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010

More...

2Simple Talk

login
Follow @xannov

| The 2DIY script archive |

Design by @xannov