ȥå   Խ ʬ Хåå ź ʣ ̾ѹ   ñ측 ǽ   إ   ǽRSS

JavaScript/tmlib.js

Last-modified: 2018-11-14 () 15:23:54 (340d)
Top / JavaScript / tmlib.js

Υ٥Ȥ˻äƿƤޤ
TechBuzztmlib.js hackthon #1 JavaScript Ȥ䤹, , Ƥ˭ˤåȡȤtmlib.jsפΥϥå󥤥٥ȳš
饤ɥ硼


tmlib.jsȤPC/iPhone/AndroidʤɤΥ֥饦ưwebץȯǤJavaScript饤֥Ǥ ƥȥǥFTPեȤȤdzȯǤΤǤjsdo.itȤ֥饦html/css/JavaScriptʤɤγȯԤwebӥdzȯޤ 餬ܤ饦ǤơΤ褦ʼǴñ˳ȯǤޤ

  1. twitter, facebookʤɤjsdo.it˥
  2. ʬѤΥե̾(papuujp)
  3. Start codingܥ򲡤ȡ¤index.html, index.js, style.cssоǺ졢֥饦ԽǽȤʤ
  4. +ܥǻȤJavaScript饤֥(jQuery Mobile, tmlib.js, enchant.jsʤ)ɲä
  5. index.js˺ꤿɤ񤤤ơcommand + s(mac)control + s(windows)¸ȡץӥ塼ɥɽ

jsdo.itβȤȡFTPǥåפʤƤ⥵оǤ˸줿֤ǻ뤳ȤǤ 㤨кäץϤȤʤޤޥ䥹ޥ۾λإ饤ɤǼ򺸱ư򤱤륲Ǥ
http://jsrun.it/papuujp/star-game2
ǤơȤʤޤȤ뤳ȤǽǤ
http://jsdo.it/papuujp/star-game2
jsdo.itȤiPadǤwebץ곫ȯԤʤޤJavaScriptjQuery Mobileʤɤμ½ٶȤǤڤ˻ȤǤ
ʥǥХåǽ夤ΤǡGoogle Chrome Developerġ˳ФȤȤⶵƤޤȤƤǤ

tmlib.jsȤϼΤ褦˿ʲǽ򴶤ޤ

  • ڤ˻
  • ˥᡼Ȥ
  • ޥۥåPCǤΥޥΰ㤤ۼξбwebץ
  • AppStoreȤ˸ʤǤ⤹˥åwebץǤ
  • facebookץ줽
  • Titanium MobileWebViewơɽå˻Ȥ


tmlibDz뤫ϡԥ󤭤ǤǤ
http://jsdo.it/search?q=tmlib

Υ塼ȥꥢ

phiἫȤΥ塼ȥꥢ뤬ȤƤʬ䤹ƥǤޤ¤줿Υ⻲ͤˤʤޤ


tmlib.jsѤ塼ƥ󥰥ֺư줫饳ɤ񤤤Ƥʬ䤹Ǥ


Υ塼ȥꥢ⥪Ǥ͡ॹڡڤäƤƹԵɤߤǤϿåॵץΤ褦ˡtm.define()פȤä褦Ǥܤ㤤Ϥ褯ʬޤ

饹ˤĤ

ǽtm.createClass()פǺäƤΤǤtm.define()פȤΤǤ


͡ॹڡ̾֡ˤ򤭤äʬƥ饹ˡϼΥץ뤬ʬ䤹äǤ饤֥곫ȯǤʤץ곫ȯξϡ͡ॹڡʬʤ䤹Ƥ⤷ޤ


Τ褦Τ¨¹ԴؿȤ¾Υ饤֥꤫鸫ʤΤʬ䤹ɤǤͤȤ ¤ tmlib

(function TouchTheNumber() {
	// screen 
	var SCREEN_WIDTH    = 680;
	var SCREEN_HEIGHT   = 960;
	...
	... tm.main()ƥ
	...
})();

˥᡼ˤĤ

tm.app.Tweener

tm.app.TweenerѤŪʻּǥ˥᡼Ѥ߽ŤͤɽǤޤʤɾܤϥ򸫤ΤɤǤ

tm.app.Timeline

tm.app.TimelineѤŪʻּǥ˥᡼ɽǤޤʤɾܤϥ򸫤ΤɤǤ

tm.app.Timelineμʥ᥽å

  • clear: ޤǤΥ˥᡼򥯥ꥢ
  • set: ˥᡼̵ǻꤷͤ
  • to: ꤷͤޤǥ˥᡼
  • by: ­ͤޤǥ˥᡼

to, by줾ΰ

  • props: ܻؤͤޤ­ͤ{}˵ x, y, scaleX, scaleY, alpha
  • duration: ˥᡼֤ʥߥá
  • delay: ˥᡼󳫻ϻ֤ʥߥá
  • fn: "easeOutExpo"Ȥä˥᡼Τʥ󥰡ˤ

"easeOutExpo"Ȥä˥᡼ΤǤ

˥ڥå

// main 
tm.main(function() {
    alert("tmlib.js ȻȤƤ");
});

var Hoge = tm.createClass({
    init: function(num) {
        this.num = num;
    },
    toString: function() {
        return "οͤ{num}Ǥ!!".format(this);
    }
});
var hoge = Hoge(128);
document.write(hoge.toString());
document.write("<br />");

ͥߡ饹

ѿenemyListȤäŨٶˤʤäΤǥѤޤդƸٶˤʤޤ

#pre{{
/*
* Хѿ
*/
var enemyList = null;

/*
* ͥߡ
*/
var Enemy = tm.createClass({
superClass: tm.app.StarShape,
//
init: function() {
this.superInit(PLAYER_SIZE, PLAYER_SIZE);
},
//
update: function(app) {
this.y += 8; // ư
this.rotation += 15; // ž
// Ƚ
if (this.y > SCREEN_HEIGHT) {
this.remove();
enemyList.erase(this);
}
}
});

// ᥤ󥷡
var MainScene = tm.createClass({
superClass: tm.app.Scene,
init: function() {
this.superInit();

enemyList = [];

// ץ쥤䡼
this.player = Player();
this.addChild(this.player);
this.player.x = SCREEN_CENTER_X;
this.player.y = SCREEN_HEIGHT-100;
},

update: function() {
// ͥߡ
if (app.frame % 8 == 0) {
// ͥߡ
var enemy = Enemy();
enemy.x = tm.util.Random.randint(0, SCREEN_WIDTH);
enemy.y = -50;
this.addChild(enemy); // ɲ
enemyList.push(enemy); // ꥹȤɲ
}

// ץ쥤䡼, ͥߡȽ
for (var i=0,len=enemyList.length; i<len; ++i) {
var enemy = enemyList[i];
// Ƚ
if (this.player.isHitElement(enemy)) {
// Game Over
app.replaceScene(ResultScene());
}
}
}
});
}}