New image() and question regarding it

ha all, first of all im new in programing and js is my first programing lenguage. my quation is: why soe times image dont runs when i add it on the canvas throught js? i did img.onload=()=>{ draw image} but even so, it does not work

var hero = new Image()

hero.src=sprites.hero

hero.onload=()=>{

contexto.drawImage(hero, 0, 0, 32, 32, 20, 29, 52, 61)

}

Hello and welcome, Iā€™m having difficulty reading you post try downloading the spell checker to help you. I just did and it works great.

1 Like