<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>いちばんやさしいゲームの作り方 &#187; ActionScript</title>
	<atom:link href="http://www.game-create.com/archives/tag/actionscript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.game-create.com</link>
	<description>文系の人でも、数理学がわからない人でもゲームプログラミングをマスターできるブログ</description>
	<lastBuildDate>Tue, 08 Jun 2010 01:28:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CodeZine にもゲームプログラミングの入門記事がありました</title>
		<link>http://www.game-create.com/archives/2858</link>
		<comments>http://www.game-create.com/archives/2858#comments</comments>
		<pubDate>Sun, 07 Feb 2010 14:30:53 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[ウェブログ]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=2858</guid>
		<description><![CDATA[最近のお問い合わせ傾向から役立ちそうな記事をふたつ選んでみました。
ゲームプログラミング入門：CodeZine（コードジン）
はじめてのActionScript 3～ライフゲームを作ってみる（1/2）：CodeZine
 [...]]]></description>
			<content:encoded><![CDATA[<p>最近のお問い合わせ傾向から役立ちそうな記事をふたつ選んでみました。</p>
<p><a href="http://codezine.jp/article/corner/99" class="external">ゲームプログラミング入門：CodeZine（コードジン）</a><br />
<a href="http://codezine.jp/article/detail/627" class="external">はじめてのActionScript 3～ライフゲームを作ってみる（1/2）：CodeZine</a></p>
<p><span id="more-2858"></span></p>
<p>ふたつ目の記事は「ゲーム」とタイトルに入っておりますが、 Flex でゲームに応用できそうな技術入門と考えていただけると非常に読みやすいかと思います。</p>
<p>プログラミング技術のポータルサイトですので、ゲームプログラミングの話題があるのも不思議ではないですね。こういったコンセプトでゲームプログラミングを専門に扱うサイトがあると嬉しい感じです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/2858/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ローディング画面を作りたいですよね</title>
		<link>http://www.game-create.com/archives/2585</link>
		<comments>http://www.game-create.com/archives/2585#comments</comments>
		<pubDate>Sun, 13 Dec 2009 14:49:55 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オリジナルゲーム制作]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Win32API]]></category>
		<category><![CDATA[テクスチャ]]></category>
		<category><![CDATA[ファイル]]></category>
		<category><![CDATA[まどか]]></category>
		<category><![CDATA[入出力]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=2585</guid>
		<description><![CDATA[まどかの同人作品。先のミーティングでローディング画面に触れました。そんなにロード時間はかからない見込みですが、ロード中の画面とか作りたくなる可能性もありまして、ちょっと手法を調べておりました。

Windows で非同期 [...]]]></description>
			<content:encoded><![CDATA[<p>まどかの同人作品。先のミーティングでローディング画面に触れました。そんなにロード時間はかからない見込みですが、ロード中の画面とか作りたくなる可能性もありまして、ちょっと手法を調べておりました。</p>
<p><span id="more-2585"></span></p>
<p>Windows で非同期読み込みというのをやったことが無く、どうやって実現するのか MSDN で探していたのですが、 CreateFile() にてファイルを開く際に FILE_FLAG_OVERLAPPED を指定し、続く API に OVERLAPPED 構造体のデータを作って渡すと、その API のファイル入出力が非同期になるそうです。</p>
<p>うそー、そんな簡単に。</p>
<p>もちろん、非同期読み込みならではの注意点をすべてケアしないといけなくなるわけですが、近いようなことは ActionScript でやってきたのでうまくいけばいいなぁ、と思います。ただ、描画に影響しないのかは実際にやってみないとわかりません。</p>
<p>当初の予定通り SQLite を使うようにすると非同期読み込みは簡単みたいです。 SELECT を投げたら、あとはループでぐるぐる回して、 if 文で「読み込み終わった？」というのを確認することができるとのこと。</p>
<p>ただ、どっちにしても DirectX なんかでテクスチャを生成するのに時間がかかったら意味ないかもしれません。ロード画面でアニメーションがカクッってなりそうです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/2585/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>イベントを送出できるのは特性だけど、受け取れるのも特性だろうか？</title>
		<link>http://www.game-create.com/archives/2450</link>
		<comments>http://www.game-create.com/archives/2450#comments</comments>
		<pubDate>Fri, 13 Nov 2009 14:01:13 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[ゲームプログラミング]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Maps API]]></category>
		<category><![CDATA[イベント]]></category>
		<category><![CDATA[クラス]]></category>
		<category><![CDATA[同人ゲーム]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=2450</guid>
		<description><![CDATA[念願のハンディパソコンが届きましたので、移動中とか眠りに落ちる直前とかまで同人ゲームの設計をやっております（これでネットにつながれば文句ないです）。…で、ちょっと悩み事が出て参りました。
ActionScript による [...]]]></description>
			<content:encoded><![CDATA[<p>念願のハンディパソコンが届きましたので、移動中とか眠りに落ちる直前とかまで同人ゲームの設計をやっております（これでネットにつながれば文句ないです）。…で、ちょっと悩み事が出て参りました。</p>
<p>ActionScript によるコンテンツ制作があまりに楽だったので、それを参考にしているのも悪いのですが、イベントを送出するという特性に対して、受け取るという特性も必要か迷っております。</p>
<p><span id="more-2450"></span></p>
<p>ActionScript では EventDispatcher 、もしくは IEventDispathcer を実装して内部でイベントを処理できるオブジェクトのみがイベントを送出できます。具体的にイベントを構築したり（プログラマが設定できない情報を登録する currentTarget とか）伝播させたりするのはコアのエンジンがやりそうな気もしますので、イベントの送出に特性が必要なのはたぶん仕方ないのだと思います。</p>
<p>ただ、イベントを受け取ることには特性はいらないような気がするのです（今、想定しているゲームの要件ならという条件付きですが）。実は ActionScript もそうなっているのですが、イベントを待ち受けるのに addEventListner() を使わねばならず、これのインタフェースと実装が IEventDispatcher と EventDispathcer にあります。ちょっと、イベントを受け取るという振る舞いを想像するのに Dispatch という単語がピンとこなくて悩んでいました。</p>
<p>Google Maps API なんかですと、イベントは誰でも受け取れて、リスナー登録はイベントクラスの静的メソッドで実現します。こういうの良いかもなぁ…、なんて思ったのですが、これだと private なイベントハンドラが登録できなそうです。</p>
<p>よくわからないのに無理にオブジェクト指向っぽくしているのがいけません。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/2450/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>継承ツリーが長くならないようなアプローチが必要かも</title>
		<link>http://www.game-create.com/archives/1995</link>
		<comments>http://www.game-create.com/archives/1995#comments</comments>
		<pubDate>Thu, 23 Jul 2009 16:15:01 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オリジナルゲーム制作]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[DisplayObjectContainer]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[MovieClip]]></category>
		<category><![CDATA[クラス]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1995</guid>
		<description><![CDATA[Flash アニメーションが作りやすくて、なんとかこの作りやすさを C++ でもと参考にしてゲームを作っているのですが、やはり継承ツリーの長さが気になります。

ゲームの基本的な要素である Sprite と Flash  [...]]]></description>
			<content:encoded><![CDATA[<p>Flash アニメーションが作りやすくて、なんとかこの作りやすさを C++ でもと参考にしてゲームを作っているのですが、やはり継承ツリーの長さが気になります。</p>
<p><span id="more-1995"></span></p>
<p>ゲームの基本的な要素である Sprite と Flash の基礎的な要素である MovieClip までの継承ツリーを見てみると次のようになります。</p>
<table class="style-1">
<caption>MovieClip の継承関係（上が基底クラス）</caption>
<tr>
<th>Object</th>
<td>全てのオブジェクトの祖。</td>
</tr>
<tr>
<th>EventDispatcher</th>
<td>イベントを受け取ったり、送出したり、ラジバンダリできるようになる。</td>
</tr>
<tr>
<th>DisplayObject</th>
<td>Flash ムービーとして表示するのに必要な情報が管理できるようになる（大きさとか座標とか回転度とか不透明度とか）。</td>
</tr>
<tr>
<th>InteractiveObject</th>
<td>マウスやキーボードに反応できるようになる。</td>
</tr>
<tr>
<th>DisplayObjectContainer</th>
<td>DisplayObject をツリー状に内包できるようになる。知らなかったけどゲームを作るのに便利なパターンらしい。</td>
</tr>
<tr>
<th>Sprite</th>
<td>実際に Flash ムービーの画面に表示できるようになる（これより前の表示関連のクラスは抽象クラス）。</td>
</tr>
<tr>
<th>MovieClip</th>
<td>タイムラインを持った Sprite 。これなくして Flash はないが、 Flash なくしてこれはない、というのは言い過ぎ。</td>
</tr>
</table>
<p>長いです。そして、表現する物によっては要らない機能もあります。たとえばダッシュして巻き上げた砂のエフェクトなんかがイベントを送出したり受け取ったりできる必要はありません。ゲームによってはひとつひとつの表示オブジェクトが入力を受け付ける機能が不要になることも多いかと思います。</p>
<p>インタフェースによる代表的な実装を持つオブジェクトへの委譲などで、ひとつひとつのオブジェクトを軽量化できないか検討が必要のようです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1995/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash が IK に対応している件</title>
		<link>http://www.game-create.com/archives/1955</link>
		<comments>http://www.game-create.com/archives/1955#comments</comments>
		<pubDate>Tue, 14 Jul 2009 16:09:33 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[ウェブログ]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[IK]]></category>
		<category><![CDATA[スパロボ]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1955</guid>
		<description><![CDATA[いつもながら、「どこに行くのか？」感ただよう Flash の進化ですが、ついに IK に対応したようです。
第2回：Flashの新機能、IKって何？

でも、考えようによっては表示ツリーとの相性が良くて Flash には [...]]]></description>
			<content:encoded><![CDATA[<p>いつもながら、「どこに行くのか？」感ただよう Flash の進化ですが、ついに IK に対応したようです。</p>
<p><a href="http://thinkit.jp/article/747/1/" class="external">第2回：Flashの新機能、IKって何？</a></p>
<p><span id="more-1955"></span></p>
<p>でも、考えようによっては表示ツリーとの相性が良くて Flash にはもってこいなのかもしれません。関節かぁ、関節ねぇ、でも、スパロボのアニメーションとは毛色が違いますよね（まだ、野望の火はくすぶっております）。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1955/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>仕事で Flash のことを訊かれたので答えてみました</title>
		<link>http://www.game-create.com/archives/1835</link>
		<comments>http://www.game-create.com/archives/1835#comments</comments>
		<pubDate>Fri, 19 Jun 2009 09:25:34 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オーサリングツール]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[VC++ 2008 EE]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[アニメーション]]></category>
		<category><![CDATA[コンパイラ]]></category>
		<category><![CDATA[デバッガ]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1835</guid>
		<description><![CDATA[同じ疑問をお持ちの方がいらっしゃいましたら参考にしてみて下さい。

Flash が無いと SWF は作れないの？
いいえ、 Flex SDK があれば無償で SWF を作ることができます。
Flash と Flex SD [...]]]></description>
			<content:encoded><![CDATA[<p>同じ疑問をお持ちの方がいらっしゃいましたら参考にしてみて下さい。</p>
<p><span id="more-1835"></span></p>
<h4>Flash が無いと SWF は作れないの？</h4>
<p>いいえ、 Flex SDK があれば無償で SWF を作ることができます。</p>
<h4>Flash と Flex SDK はどう違うの？</h4>
<p>Flash を Visual C++ のような IDE と考えると、 Flex SDK は cl.exe とか link.exe とか nmake.exe みたいなものです。ただし、 Flex SDK にて SWF を作るためには JRE （ Java のランタイム）が必要です。</p>
<h4>Flash を買う意味あるの？</h4>
<p>アニメーション要素のあるムービーを低コストで作りたい場合は大いにあります。 Flash があればモーションをマウスでつけることができますし、モーションの惰性も二次元のグラフで簡単に指定できます。描画ツールもありますので、単純な図形をマウスやペンタブレットで描くこともできます。</p>
<p>もし、 Flash を使わない場合は、座標や回転値などのモーションデータをオブジェクトと数値で指定するか、 XML で指定なければなりません。</p>
<h4>あなたはアニメーションを作れないのに、なぜ Flash を持ってるの？</h4>
<p>デバッガが便利なのと、 Creative Suite にバンドルされていたからです。仕事で作った SWF は Stage のタイムラインの１フレームに起動コードがあるだけで、あとは ActionScript で構築しました。ここだけ見ると無駄なんですが、それを無駄と思わせないのはデバッガの存在が大きいと思います。</p>
<h4>簡単に覚えられる？</h4>
<p>なんらかのプログラミング言語の経験がある方にとっては、携帯 Flash や昔の Flash に比べたら遙かに難度は低いと思います。 Flash は Macromedia 時代からそうだったのですが、マニュアルが非常に良くできていて、情報源に不足がありません（トピック毎にコピペで動くサンプルがあるのが嬉しいです）。ただ、全く初めての場合は、入門書に頼った方が良いと思います（少なくともタイムラインが問題なく使えるようになるまでは）。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1835/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ゲームの土台がだんだん Flash っぽくなってきてます</title>
		<link>http://www.game-create.com/archives/1789</link>
		<comments>http://www.game-create.com/archives/1789#comments</comments>
		<pubDate>Sat, 06 Jun 2009 16:10:28 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オリジナルゲーム制作]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[MovieClip]]></category>
		<category><![CDATA[クラス]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1789</guid>
		<description><![CDATA[命大事にしつつガンガンいろいろがんばって呪文節約しながらゲームを作っております。

ゲームというソフトウェアを作るためのプログラム構築方法には、実に多くのバリエーションがあるということなど今更言う必要もないと思います（で [...]]]></description>
			<content:encoded><![CDATA[<p>命大事にしつつガンガンいろいろがんばって呪文節約しながらゲームを作っております。</p>
<p><span id="more-1789"></span></p>
<p>ゲームというソフトウェアを作るためのプログラム構築方法には、実に多くのバリエーションがあるということなど今更言う必要もないと思います（でも、本当は言った方が良いような気もします）。</p>
<p>最近、インタラクティブに動くコンテンツの制作手法として Flash の実績が見過ごせなくなってきました。つまり、「 Flash の手法ってゲームが作りやすいなぁ」ということです。思わず、今、作っているゲームのクラス階層が ActionScript のそれに近くなってしまいました。</p>
<p>ただ、 ActionScript は「肥大化した MovieClip を再分析する」という歴史があるのを忘れてはならないと思います。つまり、今、ゼロから ActionScript を構築したら、同じクラス階層になるのかという視点が重要なのでは無かろうかということです。</p>
<p>自分のゲームに取り込んで良い物か悩みます。でも、作りやすいです。次のゲームが 2D だからなおさら悩むのかもしれません。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1789/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>内容がない表示オブジェクトの大きさはゼロ</title>
		<link>http://www.game-create.com/archives/1685</link>
		<comments>http://www.game-create.com/archives/1685#comments</comments>
		<pubDate>Tue, 12 May 2009 14:58:08 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オーサリングツール]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[DisplayObject]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[画像]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1685</guid>
		<description><![CDATA[



Flash で謎のバグに悩まされていたのですが、どうやら内容がない表示オブジェクトの大きさが変更できないことが原因だったようです。自分で width とか指定してもだめなんですね。マニュアルに書いてありました。
 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.game-create.com/wp-content/plugins/wp-tegaki/wp-tegaki-img.php?tegaki_id=1685-0&amp;page=1" alt="そう　ゼロゼロゼロ　それは始まりの場所" width="435" height="34" /><br />
<img src="http://www.game-create.com/wp-content/plugins/wp-tegaki/wp-tegaki-img.php?tegaki_id=1685-1&amp;page=1" alt="またそこに立てば何か始まり" width="297" height="34" /><br />
<a href="http://www12.plala.or.jp/vitality/tamurapan/"><img src="http://www.game-create.com/wp-content/plugins/wp-tegaki/wp-tegaki-img.php?tegaki_id=1685-2&amp;page=1" alt="by あゆみお姉さん" width="149" height="27" /></a></p>
<p><span id="more-1685"></span></p>
<p>Flash で謎のバグに悩まされていたのですが、どうやら内容がない表示オブジェクトの大きさが変更できないことが原因だったようです。自分で width とか指定してもだめなんですね。マニュアルに書いてありました。</p>
<p>たとえば画像ファイルのデータを内容に持つ表示オブジェクトを作ろうとするとき、画像ファイルを非同期に読み込んでしまうと、読み込まれて addChild() するまで表示オブジェクトの大きさが０になります（ width や height に値を入れても反映されません）。</p>
<p>ちなみに Graphics オブジェクトを使って描画したグラフィックでも内容と見なされるようです。表示ツリーに入らない四角形とかも内容としては十分です。ですので、目的の表示オブジェクトの大きさが決まっているのであれば、最初になんらかのグラフィックを描いておくのも手だと思います。</p>
<p>非同期って難しいですね。でも、ゲームプログラミングではよくあることだと思いますので勉強しています。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1685/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript を使う場合はメンバ変数を m_ とかで修飾するポリシーが良いかもしれません</title>
		<link>http://www.game-create.com/archives/1527</link>
		<comments>http://www.game-create.com/archives/1527#comments</comments>
		<pubDate>Mon, 20 Apr 2009 11:53:45 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オーサリングツール]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[クラス]]></category>
		<category><![CDATA[メンバ]]></category>
		<category><![CDATA[変数]]></category>
		<category><![CDATA[関数]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1527</guid>
		<description><![CDATA[…というのも、以下のコードがエラーになるのです。
public class SomeClass
{
  private var member:String;
  // ↓オーバーロードできねぇ！
  public [...]]]></description>
			<content:encoded><![CDATA[<p>…というのも、以下のコードがエラーになるのです。</p>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-reserved">public class </span><span class="hl-identifier">SomeClass
</span><span class="hl-brackets">{
  </span><span class="hl-reserved">private </span><span class="hl-identifier">var member</span><span class="hl-code">:</span><span class="hl-identifier">String</span><span class="hl-code">;
  </span><span class="hl-comment">// ↓オーバーロードできねぇ！
  </span><span class="hl-reserved">public </span><span class="hl-identifier">function set member</span><span class="hl-brackets">(</span><span class="hl-identifier">member</span><span class="hl-code">:</span><span class="hl-identifier">String</span><span class="hl-brackets">)</span><span class="hl-code">:</span><span class="hl-types">void
  </span><span class="hl-brackets">{
    </span><span class="hl-reserved">this</span><span class="hl-code">.</span><span class="hl-identifier">member</span><span class="hl-code"> = </span><span class="hl-identifier">member</span><span class="hl-code">;
  </span><span class="hl-brackets">}
  </span><span class="hl-comment">// ↓こっちも！
  </span><span class="hl-reserved">public </span><span class="hl-identifier">function get member</span><span class="hl-brackets">()</span><span class="hl-code">:</span><span class="hl-identifier">String
  </span><span class="hl-brackets">{
    </span><span class="hl-reserved">return this</span><span class="hl-code">.</span><span class="hl-identifier">member</span><span class="hl-code">;
  </span><span class="hl-brackets">}
}</span></pre></div></div>
<p>ECMA の新しい仕様は全く把握しておりません。 getter, setter といっても関数の延長なんでしょうか。</p>
<p><span id="more-1527"></span></p>
<p>普段は、「 this をつければメンバかパラメータか区別できるでしょう」という考えの下、メンバ変数にプリフィクスやサフィックスをつけないのですが、広く使われているパターンですし、私も m_ とかつけるポリシーに移行しようか検討しています。</p>
<p>まだ、本格的なゲームのコードを書いていないだけに迷います。今なら何とでもできますが、考えすぎても時間がもったいありません。</p>
<p>でも、 C# ならもっとうまくいけたような気がします。 getter, setter に名前が要らなかったような気が…（メンバ変数名が採用されるとか）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1527/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash のモーション XML エレメントを自作してみた</title>
		<link>http://www.game-create.com/archives/1514</link>
		<comments>http://www.game-create.com/archives/1514#comments</comments>
		<pubDate>Wed, 15 Apr 2009 15:30:24 +0000</pubDate>
		<dc:creator>Byerkut</dc:creator>
				<category><![CDATA[オーサリングツール]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[インスタンス]]></category>

		<guid isPermaLink="false">http://www.game-create.com/?p=1514</guid>
		<description><![CDATA[話題のモーション XML エレメントですが、奇跡的に仕事で使うタイミングがあったので自作してみました。
本当はこれを他のプログラムで利用する方法が一番知りたかったのですが、まぁ、それをやるにもフォーマットを知る必要があり [...]]]></description>
			<content:encoded><![CDATA[<p>話題の<a href="http://www.game-create.com/archives/1308">モーション XML エレメント</a>ですが、奇跡的に仕事で使うタイミングがあったので自作してみました。</p>
<p>本当はこれを他のプログラムで利用する方法が一番知りたかったのですが、まぁ、それをやるにもフォーマットを知る必要がありますので、わかったことを残しておきます。</p>
<p><span id="more-1514"></span></p>
<p>まず、モーション XML エレメントというのは、 IDE から使う場合は必要な項目をガッチガチに固めてやらないとまずいっぽいのですが、以下のように ActionScript から使う場合は必要な項目だけ設定してやれば良さそうです（とりあえず動きました）。</p>
<div class="hl-surround" style="height:280px;"><div class="hl-main"><pre><span class="hl-reserved">import </span><span class="hl-identifier">fl</span><span class="hl-default">.</span><span class="hl-identifier">motion</span><span class="hl-default">.</span><span class="hl-identifier">Animator</span><span class="hl-default">;

</span><span class="hl-identifier">var theShape</span><span class="hl-default">:</span><span class="hl-identifier">Shape</span><span class="hl-default"> = </span><span class="hl-reserved">new </span><span class="hl-identifier">Shape</span><span class="hl-brackets">()</span><span class="hl-default">;
</span><span class="hl-identifier">theShape</span><span class="hl-default">.</span><span class="hl-identifier">graphics</span><span class="hl-default">.</span><span class="hl-identifier">beginFill</span><span class="hl-brackets">(</span><span class="hl-number">0x0000FF</span><span class="hl-brackets">)</span><span class="hl-default">;
</span><span class="hl-identifier">theShape</span><span class="hl-default">.</span><span class="hl-identifier">graphics</span><span class="hl-default">.</span><span class="hl-identifier">drawRect</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">100</span><span class="hl-code">, </span><span class="hl-number">100</span><span class="hl-brackets">)</span><span class="hl-default">;
</span><span class="hl-identifier">theShape</span><span class="hl-default">.</span><span class="hl-identifier">graphics</span><span class="hl-default">.</span><span class="hl-identifier">endFill</span><span class="hl-brackets">()</span><span class="hl-default">;

</span><span class="hl-identifier">addChild</span><span class="hl-brackets">(</span><span class="hl-identifier">theShape</span><span class="hl-brackets">)</span><span class="hl-default">;

</span><span class="hl-identifier">var theMotion</span><span class="hl-default">:</span><span class="hl-identifier">XML</span><span class="hl-default"> =
  &lt;</span><span class="hl-identifier">Motion duration</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">10</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">xmlns</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">fl.motion.*</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">xmlns</span><span class="hl-default">:</span><span class="hl-identifier">geom</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">flash.geom.*</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">xmlns</span><span class="hl-default">:</span><span class="hl-identifier">filters</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">flash.filters.*</span><span class="hl-quotes">&quot;</span><span class="hl-default">&gt;
    &lt;</span><span class="hl-identifier">Keyframe index</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100</span><span class="hl-quotes">&quot;</span><span class="hl-default">&gt;
      &lt;</span><span class="hl-identifier">color</span><span class="hl-default">&gt;
        &lt;</span><span class="hl-identifier">Color alphaMultiplier</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
      &lt;/</span><span class="hl-identifier">color</span><span class="hl-default">&gt;
      &lt;</span><span class="hl-identifier">tweens</span><span class="hl-default">&gt;
        &lt;</span><span class="hl-identifier">CustomEase target</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">position</span><span class="hl-quotes">&quot;</span><span class="hl-default">&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.1</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.1</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.2</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.15</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.3</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.2</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.4</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.25</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.5</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.3</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.6</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.35</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.7</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.4</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.8</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.45</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
          &lt;</span><span class="hl-identifier">geom</span><span class="hl-default">:</span><span class="hl-identifier">Point x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.9</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">0.75</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
        &lt;/</span><span class="hl-identifier">CustomEase</span><span class="hl-default">&gt;
        &lt;</span><span class="hl-identifier">SimpleEase target</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">color</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
      &lt;/</span><span class="hl-identifier">tweens</span><span class="hl-default">&gt;
    &lt;/</span><span class="hl-identifier">Keyframe</span><span class="hl-default">&gt;
    &lt;</span><span class="hl-identifier">Keyframe index</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">9</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">x</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">400</span><span class="hl-quotes">&quot; </span><span class="hl-identifier">y</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">200</span><span class="hl-quotes">&quot;</span><span class="hl-default">&gt;
      &lt;</span><span class="hl-identifier">color</span><span class="hl-default">&gt;
        &lt;</span><span class="hl-identifier">Color alphaMultiplier</span><span class="hl-default">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">1.0</span><span class="hl-quotes">&quot;</span><span class="hl-default"> /&gt;
      &lt;/</span><span class="hl-identifier">color</span><span class="hl-default">&gt;
    &lt;/</span><span class="hl-identifier">Keyframe</span><span class="hl-default">&gt;
  &lt;/</span><span class="hl-identifier">Motion</span><span class="hl-default">&gt;;

</span><span class="hl-identifier">var theAnimator</span><span class="hl-default">:</span><span class="hl-identifier">Animator</span><span class="hl-default"> = </span><span class="hl-reserved">new </span><span class="hl-identifier">Animator</span><span class="hl-brackets">(</span><span class="hl-identifier">theMotion</span><span class="hl-code">, </span><span class="hl-identifier">theShape</span><span class="hl-brackets">)</span><span class="hl-default">;
</span><span class="hl-identifier">theAnimator</span><span class="hl-default">.</span><span class="hl-identifier">play</span><span class="hl-brackets">()</span><span class="hl-default">;</span></pre></div></div>
<p>初めて見る方は驚かれるかもしれません。なんと ActionScript は XML をソースコード中に組み込むことができるんですね（ PHP などでは文字列として用意してパースしなければなりません）。</p>
<p>以下、ポイントです。</p>
<ul>
<li>この XML で動かしたい表示オブジェクトを最初に構築しておく（上記コード中の theShape オブジェクト）</li>
<li>Motion 要素の duration 属性に総フレーム数を指定する（上記コードは 10 フレームとなる）</li>
<li>キーフレームの数だけ Keyframe 要素を追加する（上記コードは２つのキーフレームがある）</li>
<li>Keyframe 要素の index 属性にフレーム番号を指定する（０から始まる点に注意）</li>
<li>Keyframe 要素に x, y, scaleX, scaleY, skewX, skewY, rotation といった、対象表示オブジェクトの位置や大きさ、回転に関する情報を指定する</li>
<li>トゥイーンを使いたい場合は Keyframe 要素内に tweens 要素を追加する</li>
<li>SimpleEase 要素はキーフレームとキーフレームの中間のアニメーションを中割で自動作成する</li>
<li>CustomEase 要素はキーフレームとキーフレームの中間のアニメーションをどういった割合で作成するか指定する（単純なトゥイーンデータでも感性がついているように動かすこともできる）</li>
</ul>
<p>XML が用意できたら Animator クラスを使ってアニメーションを開始します（最後の２行）。 Animator クラスのインスタンスは参照が０にならないように注意してください。アニメーションが止まってしまいます。</p>
<p>ちなみに、「モーション XML エレメントのデータを動的に変更できないのか？」と疑問に思われるかもしれませんが、 theMotion が XML オブジェクトになっていますので、後からノードの編集は可能です。また、ソースコードに書いた XML 中で以下のようにすると変数を展開することができます。</p>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-comment">&lt;!-- variable が Flash の変数 --&gt;
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">Element </span><span class="hl-var">attribute</span><span class="hl-code">={</span><span class="hl-var">variable</span><span class="hl-code">} </span><span class="hl-brackets">/&gt;
</span><span class="hl-comment">&lt;!-- ↓ variable の中身が value の場合は以下のように展開される --&gt;
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">Element </span><span class="hl-var">attribute</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">value</span><span class="hl-quotes">&quot; </span><span class="hl-brackets">/&gt;</span></pre></div></div>
<p>もう、簡単な動きに IDE は要らなくなるかもしれません。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.game-create.com/archives/1514/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

