144
} on (release,
releaseOutside) {
_root.beetle.right=false;
}
ni
kiritamiz.
Chap tomondagi tugmani tanlab Actions – Button oynasini ochamiz
va unga
on (press) {
_root.beetle.left=true;
}
on (release, releaseOutside) {
_root.beetle.left=false;
}
ni kiritamiz.
Tepadagi tugmani tanlab Actions –
Button oynasini ochamiz
va unga
on (press) {
_root.beetle.up=true;
} on (release,
releaseOutside) {
_root.beetle.up=false;
}
ni
kiritamiz.
Pastdagi tugmani tanlab Actions – Button oynasini ochamiz
va unga
on (press) {
_root.beetle.down=true;
} on (release,
releaseOutside) {
_root.beetle.down=false;
}
ni
kiritamiz.
Mask qatlamiga o`tib obyekt harakatlnishi uchun maydon yaratamiz.
Uning ustida obyekt ko`rinishi uchun ko`rinish holatini o`chiramiz.
145
Obyekt qatlamiga o`tamiz va maydonga obyektni joylashtiramiz. Obyektni Movie
clip shakliga o`tkazamiz. Buning uchun obyektni sichqoncha bilan belgilab
sichqoncha o`ng tugmasini bosamiz va hosil bo`lgan kontekst menyudan Convert to
Symbol… bo`limini tanlaymiz. Ochilgan Convert to Symbol oynasidan Movie clip
bandini belgilaymiz va OK tugmasini bosamiz.
Obyekt tugmalarga mos harakatlanishi uchun Actions –
Movie Clip oynasini
ochamiz va unga
onClipEvent (load) {
// declare and set initial variables and properties
mode = true;
speed = 7;
//
// function used when mode
is false
function go (degree) {
_y -= speed*Math.cos(_rotation*(Math.PI/180)); _x +=
speed*Math.sin(_rotation*(Math.PI/180));
if (_rotation
_rotation += 10;
}
if (_rotation>degree) {
_rotation -= 10;
}
}
}
onClipEvent (enterFrame) {
// toggle visibility of the rotate mode button icon
146
_root.curve._visible = !mode;
//
// if
mode is true, the beetle always travels in a straight line
if (mode) {
if (up) {
_y -= speed;
_rotation = 0;
}
if (down) {
_y
+= speed;
_rotation = 180;
}
if (right) {
_x += speed;
_rotation = 90;
}
if (left) { _x -= speed;
_rotation = 270;
}
} else {
//
// if mode is false the beetle turns until it reaches its target
direction
if (up) {
go(0);
}
if (down) {
if
(_rotation>=0) {
go(180);
}
if (_rotation<0) {
go(-180);
}
}
if (right) {
if
(_rotation>=0) {
go(90);
}
if (_rotation<0) {
go(-270);
}
148
Ctrl+Enter tugmasini bosib hosil bo`lgan animatsiyani ko`rishimiz mumkin.
Sichqoncha yordamida tugmalarni bosganimizda mos
ravishta obyekt harakatlana
boshlaydi.
Biz yuqorida obyektni tugmalar yordamida harakatlantirish usulini ko`rsatib berdik.
Endi obyektni klaviatura tugmalari yordamida harakatlantirish ni ko`rib chiqamiz.
Dostları ilə paylaş: