Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript-如何从sprite工作表中删除绘制到画布的图像_Javascript_Html - Fatal编程技术网

JavaScript-如何从sprite工作表中删除绘制到画布的图像

JavaScript-如何从sprite工作表中删除绘制到画布的图像,javascript,html,Javascript,Html,(红领版的Hello World) 事情是这样的: 我处于严格模式--&& 我有一个PNG文件和一个sprite.js文件来声明并在以后定义每个图像或图形或任何你想叫它的东西&&然后在我的.html文件中,我在脚本标记的正文中有一些javascript&&我这样做: //在“sprite.js”文件中 昨晚直到今天凌晨,我在“JavaScript定义指南”中来回浏览,没有找到我需要的东西&如果能找到正确的方法,那将是非常棒的&& 你好,马克·庞切伊。>在“gmail.com上的马克·庞切伊”给我

(红领版的Hello World)

事情是这样的: 我处于严格模式--&& 我有一个PNG文件和一个sprite.js文件来声明并在以后定义每个图像或图形或任何你想叫它的东西&&然后在我的.html文件中,我在脚本标记的正文中有一些javascript&&我这样做: //在“sprite.js”文件中

昨晚直到今天凌晨,我在“JavaScript定义指南”中来回浏览,没有找到我需要的东西&如果能找到正确的方法,那将是非常棒的&&

你好,马克·庞切伊。

>在“gmail.com上的马克·庞切伊”给我打电话&谢谢。你不能真的从画布上“移除”东西;这就像从墙上刷油漆一样。你可以清除整个画布并重新绘制整个场景,或者你可以在你想要擦除的内容上绘制一些背景。>>在“gmail.com的MarkPoundcey”点击我&谢谢。你不能真的“删除”画布上的内容;这就像从墙上刷油漆一样。您可以清除整个画布并重新绘制整个场景,也可以在要擦除的内容上绘制一些背景。
var

//...etc - other stuff here ...

s_text,

//... etc - other stuff here ...

// then lower down I have this...

s_text = {

// says "Level Up !"

  NextLevel: new Sprite(img, 59, 114, 95, 19),  // - "Level Up".
    // other stuff ...
}

//... etc - other stuff here ...  // o.k. && that's it for that file &&
// I have this other file-- html5 w/ javascript in the body tag see ??
// && it says this:

if (currentstate === states.NextLevel) {
    s_text.NextLevel.draw(ctx, width2 - s_text.NextLevel.width/2, height-400);
 // how do I remove this ??

// I need to remove it && re-draw it later when a trigger event happens !!!!!

// I had a klunky way to do this that was not good:

// this works - not so good though.

delete s_text.NextLevel.x && s_text.NextLevel.y;

// "LEVEL UP!" Pic.

//but-- can't reset or make visible again when I have to re-draw it.

// I can draw another one on screen when that one is still there-- but if I 

//delete or delete the .x && .y || set them to 0; I can't get that to draw 

//again && I need to draw it 5 or more times when something triggers it:

if (score >= 15) { // score of 15 triggers this for testing.

s_text.NextLevel.draw(ctx, width2 - s_text.NextLevel.width/2, height-400);

// need to do this again-- but, won't come back up the way I am doing it &&       am ashamed to say-- I don't know how-- am I the only guy in the history of html5 to have to draw, remove and re-draw an image ??