So essentially I'm making a page where as an object move to the left as pressing right arrow key, different images would show up when the object is at different location. This is what related functions look like(I'm testing not with the image itself but by drawing an object):
function rightArrowPressed() {
var element = document.getElementById("heart");
var pos = element.style.marginLeft = parseInt(element.style.marginLeft) + 5 + 'px';
element.style.width = parseInt(element.style.width) + 1 + 'px';
console.log(pos);
}
function imageshow(){
if (pos>30 && pos<=150){
stroke(0);
strokeWeight(7);
fill(170);
rect(windowWidth/2-30, -80, 62, windowHeight+100);
console.log("yes!");
}
}
the variable pos increases fine, I can see it in javascript console, but the console in imageshow function never works.
Thank you very much!