OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/h58pcdgame/GameScriptCore...
[h58pcdgame/GameScriptCoreLibrary.git] / documents / tips
1 Tips
2 <todo>
3 アイテム生成と落下
4
5
6 <Javascript Tips>
7 document.getElementById("main").style.display = "none";
8 (mainというIDが振られている要素の表示を消す)
9 this.effectSound.pause();
10 this.effectSound.currentTime = 0;
11 this.effectSound.play();
12 this.backgroundImage = new Image();
13 this.backgroundMusic = document.getElementById('BGM006');
14 this.effectSound = document.getElementById('SE_Select');
15
16 <画像読み込み>
17 this.backgroundImage.manager = this;
18 this.backgroundImage.onload = this.backgroundLoaded;
19 this.backgroundImage.src = "title.gif";
20
21 <音楽再生>
22 this.backgroundMusic.loop = true;
23 this.backgroundMusic.play();
24
25 <IE>
26 -MicrosoftInternetExplorerでは、ローカル変数でparentを使うとappendChildが使えなくなる…。
27 -囲まれたブロックの後の末尾部分が実行されない???
28         loadStageFromNetwork: function(name){
29                 //URL_PCD_Stage/name.jsを利用してステージを作成する。
30                 request = this.networkManager.CreateRequestObject();
31                 //同期モード
32                 request.open('GET', URL_PCD_Stage + name + ".js", false);
33                 this.networkManager.RequestObjectDisableCache(request);
34                 request.send(null);
35                 
36                 if(request.status == 0){
37                         alert("ネットワークにアクセスできません。" + request.status + ":" + request.statusText);
38                 }else if((200 <= request.status && request.status < 300) || (request.status == 304)){
39                         var stage = eval(request.responseText);
40                         mainManager.runStage(stage);
41                 }else{
42                         alert("サーバーがエラーを返しました。" + request.status + ":" + request.statusText);
43                 }
44                 //なんで実行されないの????
45                 alert("1564426");
46         },
47 --以下のコードで解決できる。どこでも良いので実行させる。http://qiita.com/rev84/items/f7ca6a2af00daefa065c
48 //IE fix
49 if (!window.console){
50     window.console = {
51         log : function(msg){
52             // do nothing.
53         }
54     };
55 }
56
57 IEではXMLHTTPRequest.onreadystatechangeのthisの値が他と異なるようだ。
58 なので、
59 request.onreadystatechange = function(){
60         と無名関数で書いて、内部でrequestインスタンスを参照
61 };
62 しないとうまく動かない。