ステージ(背景)

From M.U.G.E.N Wiki

Jump to: navigation, search


概要

M.U.G.E.Nにおける背景とは、一つ以上の背景要素で構成される背景コントローラです。 様々なステージ設定が統合して、M.U.G.E.N上で動作する外観とステージの機能を提供します。

ステージ設定ではパラメータを操作します(ステージサイズ、カメラの動作、キャラクターやカメラの開始位置、影の色、床の反射等)。 背景のパラメータの値(特にステージのサイズとカメラの動作)はステージ構成が変わっても一貫して保持します。

背景要素は画面上に表示されるグラフィックデータの個々の集まりです ステージのすべての表示部分が背景要素から形成されます。 各々の背景要素は該当する項目について個々の設定をする必要があります(スプライトデータ、透明性、位置座標、タイル張り、カメラに関するスクロール速度、アニメーション)。 カメラをスクロールするとき、 Parallaxing 要素はラスタ効果を加えます。 背景要素は任意のサイズになる可能性があり、通常は適度なサイズの要素からつなぎ当てられます。

背景コントローラは背景要素に追加操作を実行します(位置や速度の変更、表示/非表示の切替えなど)。 背景コントローラは背景でキャラクターを前後へスクロールさせる、デブリが画面上を飛ぶ、設定時の背景に変化を引き起こす(船の上で戦っている時、洞窟に入ったような変化を引き起こす等)操作を含んでいます。 背景コントローラはより高度な効果をステージに引き起こしたり、特定のアニメーションのメモリ消費を抑えて最適化させることができます(多くのステージはコントローラなしで不具合なく動作します)。

ステージを作成するときは画面上の表示領域がすべて背景要素で「覆われていること」を確認する必要があります。 背景要素が覆われていない部分があると、その部分でミラーホール効果が発生するでしょう。 debugbg パラメーターを有効にすると覆われていないすべての部分がマゼンタ色の明るい陰で塞がれますが、それらの場所を探して修正した方が宜しいでしょう。

ステージでの明白な使用以外に、背景オブジェクトはタイトル画面やキャラクター選択画面、ストーリーボードにおける使用などすべてのシステム画面の背景で使用されます。 これらの背景はそれぞれ「システム背景」と「ストーリーボード背景」と呼ばれます。ステージに使用される背景オブジェクトは「ステージ背景」と呼ばれます。 本質的には背景タイプの間には違いはありません。この文書では背景オブジェクト形式とステージ設定について説明します。

ステージ設定の記述方式

ステージ設定ではステージと背景の関係を定義します。背景は同じステージファイルにまとめる必要があります。以下にいくつかのグループの記述例を示します。

(省略可能)としてマークされたパラメータを除いてすべてのパラメータが必要です

Info グループ

name = "ステージ名"
ステージの選択リストに表示する名前を設定します。

Camera グループ

startx = pos_x
X軸のカメラ開始位置を設定します。 普通は0に設定します。
starty = pos_y
Y軸のカメラ開始位置を設定します。 普通は0に設定します。
boundleft = min_x
Xの値の分だけカメラを左にスクロールさせることができます。 負の値である必要があります。値を調整することでカメラの左スクロールを制限できます。
boundright = max_x
Xの値の分だけカメラを右にスクロールさせることができます。 正の値である必要があります。値を調整することでカメラの右スクロールを制限できます。
boundhigh = min_y
Yの値の分だけカメラを上にスクロールさせることができます。 負の値である必要があります。値を調整することでカメラの上スクロールを制限できます。
boundlow = max_y
Yの値の分だけカメラを下にスクロールさせることができます。 常に0の値である必要があります。
verticalfollow = closeness
プレイヤーの最高座標に従い、カメラの垂直方向の動作に影響を与えます。 0~1の値である必要があります。0の値はプレイヤー位置を追従せずに全く上に移動しないカメラを意味します。 より1に近い値の場合はカメラはプレイヤー位置の近くまで追従します。 1の値はカメラは可能な限りプレイヤー位置まで接近して追従します。
floortension = v_dist
床からプレイヤーの最高座標までの垂直距離です(正の値を設定)。 カメラの開始位置をプレイヤーに従い移動します。
tension = h_dist
ステージ端からプレイヤー位置までの水平距離です。 カメラの開始位置をプレイヤーに従い移動します。有効値は0~160です。

PlayerInfo グループ

p1startx = x_start
プレイヤー1側のX軸の開始位置です。
p1starty = y_start
プレイヤー1側のY軸の開始位置です。
p2startx = x_start
プレイヤー2側のX軸の開始位置です。
p2starty = y_start
プレイヤー2側のY軸の開始位置です。
p1facing = facing_flag
開始時のプレイヤー1の向きを設定する。1の値で右向きに、-1の値で左向きに設定されます。
p2facing = facing_flag
開始時のプレイヤー2の向きを設定する。1の値で右向きに、-1の値で左向きに設定されます。
leftbound = x_min
プレイヤーがステージ左側にて有効な移動範囲Xを設定します。
rightbound = x_max
プレイヤーがステージ右側にて有効な移動範囲Xを設定します。

Bound グループ

screenleft = min_dist_left
プレイヤーと画面左端の最小許容距離です。 正の値である必要があります。
screenright = min_dist_right
プレイヤーと画面右端の最小許容距離です。 正の値である必要があります。

StageInfo グループ

zoffset = v_dist
画面の上から地上までの垂直距離で、ピクセル単位で指定します。 不適切なパラメータ名ですが、互換性のために現在は残されています。
zoffsetlink = elem_ID
このパラメータが指定されると、指定されたID番号を持つ背景要素のy座標にzoffset値をリンクします。 例えば, ダミー要素に sin.y パラメータをリンクすることで、キャラクターを上下に正弦波のように表現できます。(参照 その他の背景要素の種類)
autoturn = turn_flag
1の値を設定するとキャラクターは自動的に向かい合うようになります。 1以外の値に設定すると予期しない動作が発生します。
resetBG = reset_flag
1の値に設定した場合、ラウンド毎に背景がリセットされます。 0の値に設定した場合は背景の状態が続行されます。
localcoord = width, height
ステージの座標空間の大きさです。 省略された場合は、320, 240がデフォルトで設定されます。
xscale = xscale
オフセット、速度、スプライト、アニメーションの水平方向のスケール要素です。
yscale = yscale
オフセット、速度、スプライト、アニメーションの垂直方向のスケール要素です。

Shadow グループ

intensity = darkness_val (省略可能)
影の暗度を操作します。有効な値は0(明るい)~256(暗い)の範囲です。 省略された場合は、128がデフォルトで設定されます。
color = r,g,b (省略可能)
影の色に影響を与えます。``R、G、B``(0〜255の間)はプレイヤーの影の色の構成要素です。 高い値は対応する影の色が少なく、低い値は明るい影が表示されます。省略された場合は、0,0,0がデフォルトで設定されます。
yscale = scale_y (省略可能)
影の垂直方向のスケール要素です。大きな値を指定することで影が長くなります。 プレイヤーの反対側に落ちる影の場合は、負の値を指定してください。 省略された場合は、0.4がデフォルトで設定されます。
fade.range = top_y, bot_y (省略可能)
影が上に表示される範囲です。プレーヤーが地上から離れている距離を取得し、影のフェージングの効果を作成するために使用します。 最初の値は高レベル、2番目は中間レベルです。両方ともにプレイヤーのY座標を表します。 プレイヤーが高レベルを超えている場合は影は全く見えなくなり、中間レベルを下回る場合はくっきりと見ることができます。 影は2つのレベル間でフェードされます。 省略された場合は、エフェクトなしとしてデフォルトで設定されます(影が完全に表示されます)。 y軸の座標値が負であることに注意してください。TOP_Y<BOT_Yでなければなりません。

Reflection グループ

reflect = reflect_flag (省略可能)
1の値を設定すると反射の影が有効に、0で無効になります。 反射の影が"反射するピカピカの床"のエフェクトを作成し、適用されます。 省略された場合は、0がデフォルトで設定されます。

Music グループ

bgmusic = bgm_filename (省略可能)
ステージで再生される音楽ファイル名です。 音楽ファイルは sound/ ディレクトリ下に置いてください。 空白の場合は音楽ファイルがないものとみなされ、再生されません。 指定した音楽ファイルが存在しない場合、再生されません。 CDオーディオを再生するには"トラック番号.da"と指定してください. 0のトラック番号を指定するとランダムにオーディオトラックが再生されます。 例えば、音楽CDからトラック番号3を再生する場合、 bgmusic = 3.da と設定してください。 省略された場合は、音楽は再生されません。
bgvolume = volume_offset (省略可能)
再生するBGMの音量を調整します(mp3、mod、CDAのみ)。 0が標準、負の値は低音量、正の値の場合は高音量となります。 有効な値は-255~255です。省略された場合は、0がデフォルトで設定されます。

背景要素の記述方式

ステージの背景要素を定義するには始めに BGDef グループをDEFファイルの末尾に作成する必要があります。 形式は以下の通り:

[BGDef]
spr = stages/my_stage.sff
debugbg = 1

stages/my_stage.sff をステージのスプライトデータのSFFファイルがあるパスに置き換える必要があります。 よりよい動作速度環境を確保するため debugbg = 0 に設定することを忘れないでください。

一度 BGDef 定義が作成されると、DEFファイルは以降のすべてを BGDef セクションに属していると見なします。 BGDef セクションでは、1つ以上の背景要素を指定する必要があります。 背景要素はDEFファイルの上から順に描かれているので、最下層のレイヤに設定したい場合は最初に定義する必要があります(以前の要素がそれ以降の要素に上書き描写されます)。

静的な背景要素

静的なバックグラウンド要素を指定するための形式は以下の通りです。

[BG my_element_name]
type = normal
spriteno = 0,0
id = 0
layerno = 0
start = 0,0
delta = .5, .5
trans = none
mask = 0
tile = 0,0
tilespacing = 0,0
window = 0,0,319,239
windowdelta = 0,0

パラメーターの多くは省略可能です。これらの例は一つずつ検査していくつもりです。

[BG my_element_name]  ; (必須)
Only [BG] is actually required. my_element_name can be anything you want. Generally, it helps to give each element a distinct and descriptive name, since "my_element_name" is what will be used in error messages.
type = normal  ; (必須)
This specifies that this background element is a static sprite, neither animated nor parallaxing.
spriteno = 0,0  ; (必須)
This specifies which sprite in the SFF to display for this background element.
id = 0  ; (任意)
Specifies an ID number to refer to this background element by. This is used to allow background controllers to specify which elements they control. Different background elements can share the same ID number if necessary.
layerno = 0  ; (任意)
If layerno = 0, then this background element is drawn behind the characters. If layerno = 1, then this element is drawn in front of the characters. Within each layer, background elements are drawn back-to-front in the order they appear in the DEF file. layerno defaults to 0 if omitted.
start = 0,0  ; (任意)
Specifies the background element's starting position with respect to the top center of the screen (positive y values go downward). The background element's axis (the one specified for the designated sprite in the SFF) is placed at this starting position. If omitted, start defaults to 0,0.
delta = .5,.5 ; (任意)
Specifies how many pixels the background element should scroll for each pixel of camera movement in the horizontal and vertical directions, respectively. Setting delta=1,1 will cause the background element to move at the same speed as the camera. This is good for things like the ground under the characters' feet. For elements off in the distance, use smaller values of delta to create the illusion of depth. Similarly, elements in the foreground (layerno = 1) should usually be given deltas larger than 1. Setting delta to a negative value is possible, but may have an unintended effect. delta defaults to 1,1 if omitted.
trans = none ; (任意)
Specifies whether this background element should be transparent or not. Transparency modes are none, add, add1, sub. These specify no transparency (the default), color addition (spotlight effect), 50% color addition, and color subtraction (shadow effect).
mask = 0  ; (任意)
If mask is set to 1, color 0 of the sprite will not be drawn. This is used in drawing objects which are not rectangular in shape. For reasons of speed, mask should be set to 0 when not needed. mask defaults to 0.
tile = 0,0 ; (任意)
This line specifies if the background element should be repeated (tiled) in the horizontal and/or vertical directions, respectively. A value of 0 specifies no tiling, a value of 1 specifies infinite tiling, and any value greater than 1 will cause the element to tile that number of times. If this line is omitted, no tiling will be performed.
tilespacing = 0,0 ; (任意)
If tiling is enabled, this line specifies the space to put between separate instances of the tile in the horizontal and vertical directions, respectively. There is no effect if tiling is not enabled. tilespacing defaults to 0,0.
window = 0,0,319,239  ; (任意)
Specify window with four coordinates x1, y1, x2, and y2 respectively. Considering the upper left corner of the screen as (0,0), these coordinates are taken to form a rectangular box with (x1,y1) and (x2,y2) at opposite corners. At any given time, only the part of the background element that comes within this box (the "window") will be drawn. In this example, the window specified is (0,0) - (319,239), which is the entire screen. If you do not need the windowing effect, omit this line entirely.
windowdelta = 0,0  ; (任意)
Specifies the delta of the background element's window. It works similarly to the delta parameter for the background element itself. In limited situations, some interesting effects may be accomplished by using different values for delta and windowdelta (in conjunction with window). windowdelta defaults to 0,0 (no movement) if omitted.

動的な背景要素

The format for specifying an animated background element is almost exactly the same as for a normal background element. There are only three notable differences, which will be explained below.

[BG my_animated_element]
type = anim
actionno = 55

(all other parameters other than spriteno are the same as for static background elements.)

First, for the element to animate, a type of anim must be specified. Second, an "action number" (actionno) must be specified. This replaces the spriteno parameter that would be used for a normal background element. The value of actionno must be for an animation that is defined in the DEF file. In this example, since actionno is 55, Action 55 must be defined in a manner similar to the following:

[Begin Action 55]
0,0,0,0,5
0,1,0,0,5

The format is the same as specifying animations in the AIR file, so details will be omitted here. The Action definition can be placed anywhere below the original [BGDef] グループ. Typical strategies are either to define the action immediately after the element it belongs to, or else to collect all the stage's actions together at the beginning or end of the [BGDef] group.

Note that each sprite you specify in the animation has its own axis (specified in the SFF file). During animation playback, the axis of each sprite will be lined up to correspond with the axis of the background element itself.

The effect of the tilespacing parameter is different for anim-type elements compared to normal-type elements. For a normal element, the x-value of this parameter specifies the horizontal distance between the right edge of the first tile and the left edge of the second tile. In the case of an anim element, the x-value specifies the horizontal distance between the left edge of the first tile and the left edge of the second tile. This applies similarly for the y-value. The reason for the difference is because the size of an anim is not necessarily constant. tilespacing defaults to 1,1 for anim-type elements.

The final difference between animated and normal elements is that animated elements always have mask = 1.

視差的な背景要素

To see an example of a parallaxing background element, look at the floor in KFM's stage. Parallaxing background elements, as their name implies, give the illusion of parallax (the phenomenon that close objects appear to move faster than distant objects when the camera moves). Parallaxing background elements must consist of a single sprite (they cannot be animated). They also cannot be transparent.

The format is as follows:

[BG my_parallax_element]
type = parallax
spriteno = 10, 0
xscale = 1,1.75
yscalestart = 100
yscaledelta = 1.2

(all other parameters are the same as static elements, except that trans is disabled.)

The first and second xscale parameters scale the horizontal delta of the background element's top and bottom edge, respectively. (The deltas for the rest of the element are linearly interpolated between these two values.) For instance, if we specified delta = .78, .75, then the top of the sprite would move at .78 `` 1 = .78 pixels per camera unit, and the bottom would move at .75 `` 1.75 = 1.365 pixels per camera unit. xscale is responsible for creating the parallaxing effect in the horizontal direction.

yscalestart is the percentage to scale the sprite vertically when the camera is at ground level. It defaults to 100.

yscaledelta is the amount to add to the scale factor for every camera unit the camera moves up. In the example above, if the camera moves up by one unit, the scale factor will be 101.2%, and if it moves up another unit, the scale will be 102.4% and so on.

高度なパラメータ

These parameters can be added to any background element as necessary.

id = id_number
This specifies an ID number for the background element. Multiple elements can share the same ID number. The purpose of the ID number is to allow background controllers to specify which elements they are operating on. Defaults to 0 if omitted.
positionlink = link_flag
Set positionlink to 1 to lock this element's position to the position of the element immediately preceding it in the DEF file. If set to 1, the values of the start parameter for the current element are treated as an offset from the previous element's position. The delta parameter will have no effect in this case. This is useful for getting large groups of elements to move in unison; if you edit the start and delta values of the first element in the positionlink chain, the effects will be seen throughout all elements the chain. positionlink defaults to 0 if omitted.
velocity = vel_x, vel_y
Specifies initial x- and y-velocities for the background element (these default to 0). This functionality is also subsumed by the VelSet background controller.
sin.x = amplitude, period, phase
Specifies sinusoidal movement for the element in the x-direction. The first parameter is the amplitude, the second parameter is the period of the motion in game ticks, and the third parameter specifies the initial phase shift of the sinusoidal motion (defaults to 0, i.e., the element will start in the exact middle of its sinusoidal range). This parameter is basically superseded by the SinX background controller.
sin.y = amplitude, period, phase
Works the same as the sin.x parameter, but in the y-direction.

その他の背景要素の種類

Besides normal, anim and parallax background types, there is also a dummy type. As its name implies, a dummy-type background has no associated graphics. A dummy element's position is affected just like any other element type. Currently, the only use for a dummy element is to serve as a placeholder for the effect of the zoffsetlink parameter in the StageInfo グループ.

背景コントローラ

Background controllers operate on an internal timer that starts at 0 when the round starts, and increases by 1 for every game tick. When the timer reaches the controller's start time, then the controller becomes active. When the timer reaches the controller's end time, then the controller deactivates. If a positive looptime is specified for the controller, then the controller's internal timer will reset to 0 when the looptime is reached.

Background controllers must be grouped under a parent BGCtrlDef. You can use multiple BGCtrlDefs to separate the controllers into several groups. Each block of BGCtrlDef and background controllers may be placed anywhere within the [BGDef] section of the DEF file. The general format for these blocks is as follows.

[BGCtrlDef my_controller_name]
looptime = GLOBAL_LOOPTIME
ctrlID = DEFAULTID_1, DEFAULTID_2, ...

[BGCtrl my_controller_1]
type = CONTROLLER_TYPE
time = START_TIME, END_TIME, LOOPTIME
ctrlID = ID_1, ID_2, ...
(controller-specific parameters here)

[BGCtrl my_controller_2]
(etc.)

GLOBAL_LOOPTIME specifies the number of ticks after which the BGCtrlDef should reset its internal timer, as well as the internal timers of all BGCtrls it contains. To disable the looptime, set it to -1 or omit the parameter.

DEFAULTID_1, DEFAULTID_2, etc., specify the IDs of background elements to be affected by any BGCtrl that doesn't specify its own list of ctrlIDs. You can list up to 10 ID numbers for this parameter. If the line is omitted, then the default will be to affect all background elements.

START_TIME, END_TIME, and LOOPTIME are the times at which the background controller should start acting, stop acting, and reset its internal timer, respectively. If LOOPTIME is omitted or set to -1, then the background controller will not reset its own timer. (Its timer can still be reset by its parent BGCtrlDef if a GLOBAL_LOOPTIME is specified.) The background controller will be continuously active between START_TIME and END_TIME. START_TIME is required, but if END_TIME is omitted then it will default to the same value as START_TIME (so the controller will be active for 1 tick only).

ID_1, ID_2, etc., specify the IDs of background elements for this controller to act on. This list, if specified, overrides the default list specified in the BGCtrlDef. The maximum number of IDs specifiable is 10.

Below is the list of BGCtrl types and their associated parameters.

  • null

    As the name implies, this controller does nothing. It is useful mainly for debugging, when you want to quickly disable a controller without commenting the whole thing out. Simply change the type to null and comment out the old type. This controller has no additional parameters.

  • Visible

    value = visible_flag

    Sets the visibility status of the elements.

    While active, this controller sets the affected background elements to be invisible (0) or visible (1). Time will still pass for invisible elements (meaning, in the case of animated elements, that the animation will continue to progress even though it can't be seen).

  • Enabled

    value = enabled_flag

    Sets the enabled status of the elements.

    This controller either disables (0) or enables (1) the affected background elements. When an element is disabled, it is invisible and time does not pass for it (so, in the case of animated elements, any animation is paused when it's disabled).

  • VelSet

    x = vel_x

    Sets the x-velocity of the elements.

    y = vel_y

    Sets the y-velocity of the elements.

    This controller will set the x/y velocity of the affected background elements to the specified values. Velocities are measured in pixels per game tick. You can specify either or both of the x and y parameters. If either is omitted, the element's velocity in that direction will not change.

  • VelAdd

    x = vel_incr_x

    Changes the x-velocity of the elements by vel_incr_x.

    y = vel_incr_y

    Changes the y-velocity of the elements by vel_incr_y.

    This controller will add the specified values to the x/y velocity of the affected background elements. You can specify either or both of the x and y parameters. If either is omitted, the element's velocity in that direction will not change.

  • PosSet

    x = pos_x

    Sets the x-position of the elements.

    y = pos_y

    Sets the y-position of the elements.

    This controller will set the x/y coordinate of the affected background elements to the specified values. You can specify either or both of the x and y parameters. If either is omitted, the element's coordinate on that axis will not change.

  • PosAdd

    x = x_displacement

    Displaces the x-coordinate of the elements.

    y = y_displacement

    Displaces the y-coordinate of the elements.

    This controller will displace the x/y coordinate of the affected background elements by the specified values. You can specify either or both of the x and y parameters. If either is omitted, the element's coordinate on that axis will not change.

  • Anim

    value = action_no

    Changes the animation displayed by the affected elements to the specified animation number.

  • SinX

    value = amplitude, period, offset

    Changes the amplitude, period, and phase offset for the affected elements' sinusoidal motions in the x-direction. These values have the same effect as they do for the sin.x background element parameters.

  • SinY

    value = amplitude, period, offset

    Changes the amplitude, period, and phase offset for the affected elements' sinusoidal motions in the y-direction. These values have the same effect as they do for the sin.y background element parameters.

簡単な例

Suppose we want to make a person walk back and forth from (-300,0) to (300,0), right behind the main characters. We'll use background controllers to accomplish this task.

First, define the walking animations. Say that the character's walking sprites are 10,0 through 10,3 and that they face to the right.

; Walk right
[Begin Action 10]
10,0,0,0,6
10,1,0,0,6
10,2,0,0,6
10,3,0,0,6

; Walk left
[Begin Action 11]
10,0,0,0,6,H
10,1,0,0,6,H
10,2,0,0,6,H
10,3,0,0,6,H

Now start the character off at the far left edge of his range.

[BGDef]
(...)

[BG Peregrinator]
type = anim
actionno = 10
id = 10
start = -300, 0
delta = 1,1

Let's give Peregrinator a comfortable ambling speed of 2 pixels per tick. The one-way distance for his walk is 600 pixels, which will take 300 ticks. In total, it'll take him 600 ticks to make the round trip. Using this knowledge, set up the background controllers appropriately: since the entire situation repeats every 600 ticks, we can set the global looptime to 600.

[BGCtrlDef Peregrinator]
; reset the whole deal every 600 ticks.
looptime = 600
ctrlID = 10

; Set velocity of 2 pixels/sec rightward at time 0.
[BGCtrl Walk Right]
type = VelSet
time = 0
x = 2

; Set velocity of 2 pixels/sec leftward at time 300.
[BGCtrl Walk Left]
type = VelSet
time = 300
x = -2

And that's it! You can make the walk look better by having Peregrinator slow down and display a turning animation at each end of his walk. This would entail use of the VelAdd and Anim controllers. If you want Peregrinator to stop and start at regular intervals as he goes from one end to the other, you could create more VelSet and Anim controllers with their own individual looptimes (to get the behavior to repeat at regular intervals).


Personal tools