1 Araba Park Etme Oyunu Yapalım (Bölüm 1) Fri Nov 05, 2010 11:20 pm
Merhaba bu derste küçük bir park oyunu yapacağız.
İlk önce bir sayfa açalım boyutları fark etmez.
[You must be registered and logged in to see this image.]
Araba resmimizi sayfaya koyalım.
[You must be registered and logged in to see this image.]
Resmi F8 ile Movie Clip'e çevirelim.
[You must be registered and logged in to see this image.]
Arabanın Instance Name kısmına Car yazalım... Bu sonraki derslerde işe yarayacak.
Sonra Arabaya tıklayıp F9'a basarak şunları yazalım;
onClipEvent (load)
{
speed = 0;
}
onClipEvent (enterFrame)
{
if (Key.isDown(38 ))
{
speed = speed - 7.500000E-001;
}
if (Key.isDown(40))
{
speed = speed + 5.000000E-001;
}
if (Math.abs(speed) > 20)
{
speed = speed * 7.000000E-001;
}
if (Key.isDown(37))
{
setProperty("", _rotation, _rotation - 7);
}
if (Key.isDown(39))
{
setProperty("", _rotation, _rotation + 7);
}
speed = speed * 9.000000E-001;
x = Math.sin(_rotation * 1.745329E-002) * speed;
y = Math.cos(_rotation * 1.745329E-002) * speed * -1;
if (!_root.land.hitTest(_x + x, _y + y, true))
{
setProperty("", _x, _x + x);
setProperty("", _y, _y + y);
}
else
{
speed = speed * -8.000000E-001;
}
}
Araba yön tuşlarıyla hereket edecek..
Eğer ters yönde giderse;
onClipEvent (load)
{
speed = 0;
}
onClipEvent (enterFrame)
{
if (Key.isDown(40))
{
speed = speed - 7.500000E-001;
}
if (Key.isDown(38 ))
{
speed = speed + 5.000000E-001;
}
if (Math.abs(speed) > 20)
{
speed = speed * 7.000000E-001;
}
if (Key.isDown(37))
{
setProperty("", _rotation, _rotation - 7);
}
if (Key.isDown(39))
{
setProperty("", _rotation, _rotation + 7);
}
speed = speed * 9.000000E-001;
x = Math.sin(_rotation * 1.745329E-002) * speed;
y = Math.cos(_rotation * 1.745329E-002) * speed * -1;
if (!_root.land.hitTest(_x + x, _y + y, true))
{
setProperty("", _x, _x + x);
setProperty("", _y, _y + y);
}
else
{
speed = speed * -8.000000E-001;
}
}
Yazalım....
Arkaplan tasarımı ve diğer aksesuarlar 2.derste anlatılacak..
Kaynak dosyayı indirmek için tıklayın
]İlk önce bir sayfa açalım boyutları fark etmez.
[You must be registered and logged in to see this image.]
Araba resmimizi sayfaya koyalım.
[You must be registered and logged in to see this image.]
Resmi F8 ile Movie Clip'e çevirelim.
[You must be registered and logged in to see this image.]
Arabanın Instance Name kısmına Car yazalım... Bu sonraki derslerde işe yarayacak.
Sonra Arabaya tıklayıp F9'a basarak şunları yazalım;
onClipEvent (load)
{
speed = 0;
}
onClipEvent (enterFrame)
{
if (Key.isDown(38 ))
{
speed = speed - 7.500000E-001;
}
if (Key.isDown(40))
{
speed = speed + 5.000000E-001;
}
if (Math.abs(speed) > 20)
{
speed = speed * 7.000000E-001;
}
if (Key.isDown(37))
{
setProperty("", _rotation, _rotation - 7);
}
if (Key.isDown(39))
{
setProperty("", _rotation, _rotation + 7);
}
speed = speed * 9.000000E-001;
x = Math.sin(_rotation * 1.745329E-002) * speed;
y = Math.cos(_rotation * 1.745329E-002) * speed * -1;
if (!_root.land.hitTest(_x + x, _y + y, true))
{
setProperty("", _x, _x + x);
setProperty("", _y, _y + y);
}
else
{
speed = speed * -8.000000E-001;
}
}
Araba yön tuşlarıyla hereket edecek..
Eğer ters yönde giderse;
onClipEvent (load)
{
speed = 0;
}
onClipEvent (enterFrame)
{
if (Key.isDown(40))
{
speed = speed - 7.500000E-001;
}
if (Key.isDown(38 ))
{
speed = speed + 5.000000E-001;
}
if (Math.abs(speed) > 20)
{
speed = speed * 7.000000E-001;
}
if (Key.isDown(37))
{
setProperty("", _rotation, _rotation - 7);
}
if (Key.isDown(39))
{
setProperty("", _rotation, _rotation + 7);
}
speed = speed * 9.000000E-001;
x = Math.sin(_rotation * 1.745329E-002) * speed;
y = Math.cos(_rotation * 1.745329E-002) * speed * -1;
if (!_root.land.hitTest(_x + x, _y + y, true))
{
setProperty("", _x, _x + x);
setProperty("", _y, _y + y);
}
else
{
speed = speed * -8.000000E-001;
}
}
Yazalım....
Arkaplan tasarımı ve diğer aksesuarlar 2.derste anlatılacak..
Kaynak dosyayı indirmek için tıklayın