mirror of
https://github.com/microsoft/Web-Dev-For-Beginners.git
synced 2025-08-10 08:44:23 +02:00
Merge pull request #78 from qgp9/patch-6-space-game-2-drawing-to-canvas
fix loadAsset function in 6-space-game/2-drawing-to-canvas/README.md
This commit is contained in:
@@ -81,14 +81,14 @@ img.onload = () => {
|
||||
It's recommended to wrap the above in a construct like so, so it's easier to use and you only try to manipulate it when it's fully loaded:
|
||||
|
||||
```javascript
|
||||
async function loadAsset(path) {
|
||||
function loadAsset(path) {
|
||||
return new Promise((resolve) => {
|
||||
const img = new Image();
|
||||
img.src = path;
|
||||
img.onload = () => {
|
||||
// image loaded and ready to be used
|
||||
resolve(img);
|
||||
}
|
||||
resolve(img);
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user