Namespaces
Variants
Actions
Revision as of 05:35, 28 October 2011 by hamishwillee (Talk | contribs)

Archived:Flash Liteにおける基本的なキー移動機構を作成する方法

Jump to: navigation, search
Article Metadata

Code Example
Source file: Media:Key nokia.zip

Compatibility
Platform(s): Flash Lite 1.1

Article
Translated:
Last edited: hamishwillee (28 Oct 2011)

原文(英語): How to make a basic key movement in Flashlite

Flashの座標系

最初に、Flashが、各サイドに4座標を持つ座標系を持つことを知る必要があります。 基本的に、座標系はFlashのルート時間軸のようなもので、常にルート時間軸上の左上角から開始します。FlashにおけるXY軸の左上角は(0,0)です。

Flash座標系は、X軸に沿った幅(WIDTH)を、Y軸に沿った高さ(HEIGHT)を表します。

Flash座標では、X軸に沿った幅とY軸に沿った高さを表します。

ここで、ムービークリップを作成します。

16X16の四角形を描画し、それを中心に配置します。

インスタンス名は"Player"とします。

キーリスナーを追加する

on(KeyPress "<Left>"){
// Define _x axis movement.
/*The _x coordinate of a movie clip, relative to the local coordinates of the parent movie clip. Its coordinate system refers to the upper-left corner of the stage as (0,0).*/
//The width of the movie clip in pixels.
if(player. _x>(player._width/2)){
player. _x - =5;
}
}
 
on(keyPress "<Down>"){
if(player._x<(172-(player._width/2))){
player._x +=5;
}
}
 
on(keyPress "<Up>"){
// Define _y axis movement.
if(player._y>(3+(player._width/2))){
player._y -=5;
}
}
 
on(keyPress "<Down>"){
if(player._y<(203-(player._width/2))){
player._y +=5;
}
}

ダウンロード

例題コードは、下記サイトからダウンロードできます。

基本的なキーによる移動

143 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved