基本:よく使うコード

// 当たり判定
for (var i in enemies) {
	// 敵に当たったら:下記は2通り
	if (enemies[i].intersect(this)) {
	if (this.within(enemies[i], 30)) {


// ゲームクリアの画像を表示して終了
core.end(null, null, core.assets['clear.png']);
core.end(null, null, core.assets['timeup.png']);


// 画面触った、離した
bg.addEventListener('touchstart', function(e) {
	player.moving = true;
});
bg.addEventListener('touchend', function(e) {
	player.moving = false;
});


// 自機と敵の位置から弾の発射角度を求める
var sx = 相手x - this.x;
var sy = 相手y - this.y;
var angle = Math.atan(sx / sy);
// 弾を発射する
var s = new EnamyBullet(this.x+0, this.y+0,angle);
// :
// :
// 弾の移動処理
this.addEventListener('enterframe', function() {
	this.x += this.speed * Math.sin(this.angle);
	this.y += this.speed * Math.cos(this.angle);
});


// 爆発 5フレーム毎にアニメーション(Slow)
this.image = core.assets['爆発.png'];
this.addEventListener('enterframe', function() {
	if (core.frame % 5 == 0) this.frame++;
	if (this.frame == 10) this.remove();
});
core.rootScene.addChild(this);


// text
var scoreLbl = new Label();
scoreLbl.moveTo(285,280);
scoreLbl.font = "10px 'Arial', 'Monaco'";
scoreLbl.color = "#ffffff";
scoreLbl.text = 'test';
core.rootScene.addChild(scoreLbl);


// 線を4フレームの間だけ描写
var my_shot_line = enchant.Class.create(enchant.Sprite, {
	initialize: function(x, y, xx, yy) {
		enchant.Sprite.call(this, 320, 400);
		this.moveTo(0,0);
		var surface = new Surface(320,400);
		var context = surface.context;
		context.strokeStyle = 'red';
		context.lineWidth = 1;
		context.beginPath();
		context.moveTo(x, y);
		context.lineTo(xx, yy);
		context.closePath();
		context.stroke();
		this.endframe = core.frame + 4;
		this.image = surface;
		this.addEventListener('enterframe', function() {
			if (core.frame == this.endframe) this.remove();
		});
		core.rootScene.addChild(this);
	},
	remove: function() {
		core.rootScene.removeChild(this);
		delete this;
	}
});


// グループ化
var boss_group = new Group();
boss_group.moveTo(0, 0);
// 256x256のキャラの中心をグループの開始点にセット
bos.x =-128; bos.y=-128;
boss_group.addChild(bos);
// 他のスプライトも同様に開始点をずらす
var cores = new boss_core(78-128, 78-128);
boss_group.addChild(cores);
// 移動例
boss_group.tl.moveBy(200, 0, 100).and().rotateBy(360,100);

基本:演算、配列


// フレーム番号を6,7,8入れ替え
this.frame = core.frame % 3 + 6;

// フレーム番号を4,7の入れから
this.frame = this.frame == 7 ? 4 : 7;


//1次元配列
weapons = ['Tripple', 'LINE', '3x3'];
button.text = weapons[core.shot_type];


//2次元配列
var stage = [];
stage[0] = [10,8, 30,4];
stage[1] = [10,48];
stage[2] = [10,48, 60,48];
stage[3] = [10,48, 60,48, 110,48];
stage[4] = [10,64, 80,64];
core.stages = 4;

for (var i in stage[core.stage]) {
	if (i % 2 == 0)
		var bx = stage[core.stage][i];
	else
		var sz = stage[core.stage][i];

VBA:OUTLOOK:添付ファイルを自動保管&mail削除

説明:
指定のOutlookフォルダ”mailfolder”を開く
mailを後方から順番に開いて、
mailタイトルが”TEST:”で始まるかチェック
添付ファイルを指定のフォルダ”BASE_PATH”に保管してmailを削除

Const BASE_PATH As String = "c:\temp\mail\"
    
Sub export_attached_file()
    Dim myOlApp As Object, myNameSpace As Object, myFolder As Object
    Dim MAX_MAIL As Long
    Dim myItem As Object, myAttachments As Object
    Dim Title As String
        
    Title = "TEST:"
    
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    'Set myFolder = myNameSpace.PickFolder '毎回フォルダを選択させたい場合
    Set myFolder = myNameSpace.Folders("mailfolder") 'mailのフォルダ指定
    
    MAX_MAIL = myFolder.Items.Count
    Open BASE_PATH & "index_ZIP.txt" For Output As #1
        
    For j = MAX_MAIL To 1 Step -1
        'Debug.Print J
        Set myItem = myFolder.Items(j)
        Set myAttachments = myItem.Attachments
        
        '添付フアィルの数をカウント
        cu = myAttachments.Count
        
        If Left(myItem.Subject, Len(Title)) = Title Then
        
            'ファイルを保存
            For i = 1 To cu
                FN = BASE_PATH & myAttachments.Item(i).DisplayName
                myAttachments.Item(i).SaveAsFile FN
                Print #1, FN
            Next i
            myItem.Delete 'mail delete
        
        End If
        Debug.Print j
        DoEvents
    Next
    Close
    
    MsgBox "done!"

End Sub

VBA:自動ZIP解凍&退避

手っ取り早く作れる説明を別途準備しました。

実用プログラム:ZIP解凍

 

説明:
BASE_PATHが解凍先フォルダとなります。
事前にindex_ZIP.txtファイルに格納されたZIPファイルリストを
ex) index_ZIP.txt
d:\abc.zip
d:\def.zip
順番に読込ながら、解凍したファイルをBASE_PATH内に保管します。

Sub extract_zip()
    Dim zipFile As Variant, strMove As String
    Dim unzipFolder As Variant
    Dim sh As Object
    Dim REC As String, BASE_PATH as String

    BASE_PATH="d:\"

    Open "index_ZIP.txt" For Input As #1

    Do While Not EOF(1)

        Line Input #1, REC
        zipFile = REC 'zipファイル
        unzipFolder = BASE_PATH '解凍フォルダ

        Set sh = CreateObject("Shell.Application")
        sh.NameSpace(unzipFolder).CopyHere sh.NameSpace(zipFile).Items
        DoEvents

        '解凍済ZIPの退避
        strMove = Replace(zipFile, "Attachment", "Attachment\done")
        Name zipFile As strMove
    Loop

    Close

    MsgBox "done!"
End Sub

ソースを見やすく

やっと見つけた!

SyntaxHighlighterでソースを読みやすく掲載する方法
http://allabout.co.jp/gm/gc/406309/

SyntaxHighlighter Evolved – 記事にソースコードを表示するWordPressプラグイン
http://netaone.com/wp/syntaxhighlighter-evolved/