質問編集履歴

2

不必要な部分の削除

2016/11/04 06:50

投稿

Tats.N
Tats.N

スコア62

test CHANGED
File without changes
test CHANGED
@@ -114,19 +114,7 @@
114
114
 
115
115
  }
116
116
 
117
- // ctx.rect(20,20,150,100);
118
-
119
- // ctx.fillStyle = "red";
120
-
121
- // ctx.fill();
122
-
123
- // for(var i = 0; i < 5; i++){
124
-
125
- // treeArray.push(new Tree("../assets/images/tree.png",i*100,i*100))
126
-
127
- // treeArray[i].draw();
128
-
129
- // }
117
+ }
130
118
 
131
119
  }
132
120
 

1

追加情報の入力

2016/11/04 06:49

投稿

Tats.N
Tats.N

スコア62

test CHANGED
File without changes
test CHANGED
@@ -81,3 +81,53 @@
81
81
  このエラーが出ます。
82
82
 
83
83
  しかし、オブジェクトとして表示しなければ普通に表示されます。何が間違っていますか??わかる方おられましたら教えてください。お願いします。
84
+
85
+
86
+
87
+
88
+
89
+ ###追記
90
+
91
+ オブジェクトとして表示しなかった場合のコードです。
92
+
93
+ ```JavaScript
94
+
95
+ var imgTest;
96
+
97
+
98
+
99
+
100
+
101
+ window.onload = function () {
102
+
103
+ var treeArray = [];
104
+
105
+ imgTest = new Image;
106
+
107
+ imgTest.src = "../assets/images/test.png"
108
+
109
+ ctx = document.getElementById('canvas').getContext('2d');
110
+
111
+ imgTest.onload = function(){
112
+
113
+ ctx.drawImage(imgTest, 0, 0);
114
+
115
+ }
116
+
117
+ // ctx.rect(20,20,150,100);
118
+
119
+ // ctx.fillStyle = "red";
120
+
121
+ // ctx.fill();
122
+
123
+ // for(var i = 0; i < 5; i++){
124
+
125
+ // treeArray.push(new Tree("../assets/images/tree.png",i*100,i*100))
126
+
127
+ // treeArray[i].draw();
128
+
129
+ // }
130
+
131
+ }
132
+
133
+ ```