lol.. well that's one way to do it..
To simply answer your first question, you have to hide the images as well.
hideimg(index); to hide a single showimg.
or
hideimgs(min index, max index); to do a range.
Other than that, your scripting is extremely distasteful, but I suppose it'll work and I don't care to tell you much more than that.
Also, use setTimer(.05); instead of timeout=.05;
Here's a hint for making it better:
PHP Code:
function onPlayerEnters() {
onTimeOut();
}
function onTimeOut() {
setTimer(.05);
hideimgs(300, this.images); //Clear the old images
this.images = 300; //Start a new image counter
temp.maxHearts = 5; //Max heart count
for (temp.i=0;temp.i<temp.maxHearts;temp.i++) { //Loop through the possible heart values
if (temp.i>player.hearts) break; //Dont exceed the players heart count
this.images++; //"Allocate" a new image
showimg(this.images, "block.png", 32+temp.i*48, 32); //Draw the heart at the proper position.
findimg(this.images).layer = 5; //Screen-relative layer
}
}
Ya. If something doesn't work or whatever, I did type this on my phone.. But I hope you appreciate that little snippet.
}