这样的,这样的,还有这样的鼠标拖尾特效是怎么做出来的呢?小学生教我编程,侯老师编程网站上已经有很多小伙伴做了相关的教程,太棒了,这说明真正掌握了这个技巧,这也是费曼学习法的应用了。接下来我把我参考这些教程做出的鼠标拖尾特效方法 分享给大家。话不多说,开始编程。打开 scratch 编辑器之后,我们把自带的角色删除,我们从角色库里面找出来大家比较怀念的小猫,作为我们这次作品的主角, 要实现脱尾特效的话,首先这个小猫肯定不能只有一个,他应该有很多个才能有这种像移形换影的一样的效果。那我们首先呢来通过克隆的功能实现从一个角色变成多个克隆体的功能,当然我们最终可以用跳跃呀或者行走啊 来做这个脱位特效。这里呢,我们简单一点,让他呢不断的移到我们的鼠标的位置,这样的话更容易体现出来这个效果,我们让他重复执行。首先来较验一下点击率息之后,哎,这个小猫呢,就会一直跟随着我的鼠标进行移动, 并且呢他会实时的去克隆很多个这样的克隆体,很容易就把我们的屏幕给撑满了,对不对?到这个地方大家看到是不是不会再有新的克隆体出来了? 有没有同学知道为什么呢这个地方呢?答案呢,其实很明显啊,是因为我们的小猫克隆体是有上限的, 那我们的问题就变成了,你知道这个小猫克隆体他的上限是多少吗?欢迎在评论区里留言。那为了实现鼠标拖尾的特效不断的有呢,我们可以加上这样一个动作,当 克隆体启动的时候,我让他稍微等一会,比如说一秒钟让他把自己删除掉,我们再来看看效果,点击率齐好,前面是一样的哎,发现没有,我们的克隆体呢,并不会无限的增加了,因为一秒钟之后,之前克隆的那些克隆体呢,他就会 把自己删除掉了,所以我们只是数量有限的克隆体显示在舞台上面。现在呢,确实有这个拖尾的效果了,但是呢,是不是透明度没有发生变化呀,看起来有一点不是那么好看。接下来呢,我们给拖尾特效呢加上一些特殊处理就可以了,我们在这个地方克隆体启动之后呢, 让他的透明度不断的发生变化,我们在外观里面找到将虚相特效增加多少,虚相特效呢,也就是我们说的透明度增加二十五,我们给他缩小一点二 点五吧,然后呢让他重复执行四十次,这样的话虚像特效就从零变成了一百啊,也就是说从完全不透明变成了完全透明。这个等待呢,我们就不需要添加进去了,因为这个重复执行的默认带一个等待的延时,现在呢,我们来看一下效果, 走你哦,这个延时是不是看起来就已经比较不错了呢?拖尾特效看起来就比较正常了,走 哎,没问题,我们现在呢是用鼠标来控制你,完全可以呢用跳跃来实现同样的功能,这样我们就实现了突围特效的功能了,相信大家可以把这个技巧灵活的运用在 自己的作品当中,另外实现脱尾特效还是有其他的方法的,我们之前在烟花的课程中就做出过类似的效果,感兴 同学可以先思考一下,以后我们再分享另外一种制作鼠标错位特效的方法。如果你理解了本节课的内容,欢迎在评论区里回复。 ok, goodbye, 下期见!
粉丝9.1万获赞46.9万

这样的鼠标拖尾特效,侯老师之前分享了一种制作方法,视频的评论区就有其他同学留言了新的方法,侯老师学习实践后分享给大家,也希望大家能继续多多思考,多多留言。话不多说,开始编程。 打开 scratch 软件之后,我们首先呢来从扩展模块里面找出来画笔,本次我们主要用里面的图章模块来实现拖尾特效, 我们首先呢来复习一下图章本体呢,本来只有一个,我点一下图章本体呢就会生成一个新的小猫, 但是图章产生的这个小猫呢,他没有办法像克隆体那样来回的有所动作,所以呢他呢消耗电脑资源就少一点,所以当我们图章特别多的时候呢,电脑也不会变卡。然后呢,我们还需要添加一个 新的角色,我们找到长方形绘制一下,把它的填充颜色改成纯黑色,这个几乎上是覆盖了我们的整个 舞台,但是呢还是有一点偏差,我们到运动里面把它挪到正中间就可以了,零和零是正中间加上一个,当绿棋被点击,我们要用一下外观,里面有一个虚像特效,虚像特效默认为零,这个角色呢是没有什么变化的, 如果虚像特效是一百,他就是完全透明的一个状态。这一次呢,我们要用到虚像特效为九十点,一下仔细观察,你会发现舞台上其实有一个淡淡的黑色的蒙城,是刚才那个蒙城虚像特效百分之九十之后的结果。然后我们到画笔里面找到图章, 注意观察舞台的变化,随着我不断的点击图章,舞台上面的黑色是不是越来越重啊,直到呢这个小猫把它完全的给盖住了,这就是我们这一次的原理啊,我们用一个黑色的蒙城不断的产生图章的方式,把小猫产生的 图章呢慢慢的给盖住,本体呢是不受图章的影响的,所以呢,你产生图章比较早的这些小猫呢就被盖住了,刚刚产生的小猫呢就还没有被盖住,从而形成这样一个脱尾的特效。我们把整个过程呢连起来大家来看一看,就不用手续点击了, 直接让电脑呢来重复执行。小猫呢也是一样,他需要重复执行图章,同时呢跟随鼠标进行移动。 当绿棋被点击的时候呢,我们首先把默认的原来的这些呢全部擦除走。你 好,大家能看到是不是已经有这个效果了,回想一下刚才我们的原理,先产生的小猫呢,先被盖住,后产生的小猫图章呢后被盖住。好,我们还可以调整一下这个拖尾的数量,我们只需要呢把这 这个虚相特效色的再大一点,他需要比之前多很多的图章才能够完全盖住,所以呢,这个小猫显示的就会更多一些,明显比刚才更长了一些,对不对?好的,这就是评论区里面学到的另外一种方法了,如果你觉得本视频有所帮助,记得点赞收藏和分享哦! goodbye, 下期见!

粒子躲避小游戏 啊哦,大家好,欢迎收看叮咚老师的少儿编程课堂。刚刚呢,我们通过视频已经看出来了,这是一个粒子躲避的小游戏, 这个例子呢,还带有一定的拖尾效果,那我们来看一看怎么实现的?程序的开始呢,我们要绘制一个角色,这个角色里面呀,我们给他画两个造型或者三个造型都可以,这个大家自己决定。那么老师呢,画了一个圆形的一个方框,好,回到代码中, 点击小绿旗开始游戏。然后呢我们先选择一下他的初始造型,那这里呢,你可以选择造型一,就是圆,也可以选择造型二一个方框, 当然也可以是其他的造型。然后呢我们给他移到舞台的中间,接下来呢我们需要让他克隆自己,克隆的这个过程中呢,当然是要重复执行的啊,不断的去克隆自己,然后呢把他的本体啊跟着鼠标来移动, 移到鼠标指针的位置好,这样的话他就可以跟着鼠标指针来走了,我们来测试一下, 可以跟着鼠标来走了,但是你发现他后面的克隆体一直在,对吧?没有删掉。好,那我们第一步已经实现了,那接下来呢,我们要把他的克隆体来启动了, 作为克隆体启动的时候呢,我们给它设置一个初始的大小, 在这里啊,也可以放到这儿,初始大小呢,我们 给他设为五十,然后当作为克隆体启动的时候,我们只要让他的克隆体慢慢的消失就可以了,对不对?慢慢的消失啊,所以呢,我们给他最开始设置一个呃虚相的特效, 虚像特效最开始设置为零,随着他的虚像慢慢加大,他就会慢慢的看不到。好,那接下来呢,我们让他慢慢的消失,慢慢消失呢,可以给他重复这个一些次数啊,比如说我们重复五次啊,或者十十次。 好,然后呢让他的虚像虚像呢慢慢的增加,虚像特效慢慢的增加, 每次增加十,那么十次以后,他就变成了一百,对不对?一百他就看不到了,然后把大小呢也给他 慢慢的减小,最开始是,呃五十,然后重复执行十次,那每次就减五好了, 或者每次减三吧,每次减三啊,好,那么这些执行完了以后呢,我们再把这个克隆体给他删掉啊,因为这个克隆体的任务呢,他已经完成了,我们来看一下, 好,已经可以实现拖尾的效果了,对不对?好,我们现在呢把它换成造型二,重新启动一下,会变成这种方框的造型了,一种拖尾的效果。好,那么我们呢,还可以把它的颜色再发生一下变化。 颜色呢,这里有一个外观,里面将颜色特效设定为多少,我们可以给他放到这,然后呢给他一个随机数, 让它变换成这种五颜六色的,可以给它一到一百来看一下,这样的话它的颜色就会发生了变化,形成了一道彩色的拖尾。好,我们现在呢可能效果不太明显,我们给它添加一个背景, 添加一个星空的背景,这样的话大家来看一下,是不是就比较炫酷一点了?好,那到这一步呢,我们的啊拖尾效果啊就已经实现了, 那接下来呢,我们再给他增加一个箭头,添加一个角色, 好,箭头呢,给他一个初始大小,然后呢我们先从左边出线, 给他面向一个方向,面向这边 一百八十。好,我们让他从左边呢上下高度任何一个高度啊,随机出现, 点击绿旗, 然后呢我们把它的这个本体啊可以给它隐藏起来, 然后让他要干嘛?克隆自己对不对?克隆自己 好,重复执行克隆自己克隆的这个频率呢,大家可以自己决定,那我们让他 放到上面吧,一到五秒之间,随机一个时间,让他克隆一次自己。好,克隆好了以后,克隆好了以后呢,我们让他出线, 当作为克隆体启动的时候,我们让它出现。怎么出现呢?刚刚我们说过了,让它从左边的随机一个高度出现,随机高度呢就是 y 坐标随机,那我们把 x 坐标固定 移到 x, x 呢是最左边,是负的两百四十, y 坐标呢,我们就给它一个随机好了,随机多少呢?因为我们知道 y 坐标的范围是负的一百八到一百八,那我们可以给它负的一百六 到一百六,当然负的一百八到一百八也可以。好,然后让它显示出来。 好,显示出来以后呢,这个箭头要要往右边去滑动,右边滑动呢就是把 x 坐标不断增加,那我们把 x 坐标呢增加, 那这个过程呢?是不是要一直执行的?一直执行执行到什么情况下结束呢?碰到右边的边缘对不对?那我们右边的边缘呢,可以用 x 坐标来进行判定,当它大于一百六十的时候, 当它大于两百三十的时候,或者两百四十的时候呢,就表示它已经到右边的边界了,所以呢我们可以让它重复执行,直到 直到什么时候呢?直到 x 坐标大于两百三十, 这个时候呢,他已经到达右边的边缘了,那么到达右边的边缘了以后,我们就可以把这个克隆体啊给他删除了,我们现在来看一下这样的效果。 好,那么现在我发现他碰到我的例子以后,游戏还是在正常进行的,所以呢,我们在这里给他增加一个判断条件,如果他碰到了我们的例子, 就是这个角色一,我们给他改名啊,我们叫角色一,如果他碰到了这个角色一,那我们就把游戏呢结束就可以了,广播一个新消息 给它叫做结束。 好, 那么我们所有的角色当接收到这个新消息的时候呢,游戏全部停止,这是一种方式啊,这是一种方式,还有一种方式呢?我们用状态变量来表示,就是最开始啊,我们给他设置一个游戏的呃,正常状态,比如说是零, 如果说他碰到了这个粒子以后,我们把他的状态变成一,那么当检测一下啊,当这个变量变为一的时候,我们就停止全部的这个游戏啊,停止全部的脚本,这样也可以的, 那感兴趣的同学呢,可以自己去尝试一下啊。那这里呢,我们还是以广播的形式来进行,那我们在角色一里面,当接收到结束的时候,当接收到结束 的时候,我们就停止全部脚本,停止全部脚本,当然有些同学可能说了,那我在这里直接加一个停止全部脚本可不可以呢?当然是可以的,只是它的效果呢可能没有那么好,那大家可以去尝试一下。好,那现在呢,我们再来试一下, 我们去碰到一下这个例子,是不是游戏马上结束了。好,那呃,我们再来一个箭头,再添加一个箭头,这个箭头呢,我们让他从下面上去,从下面上去,那我们先把它移到下面, 把它面向的方向呢?啊?面向上边应该是九十度。好,面向九十度,那么其实 做程序呢?跟这个是呃类似的啊,跟他是类似的,只是呢他要从下面出现,那么从下面出现呢?就是呃, y 坐标固定, x 坐标呢?随机。那我们把它这样一换, 负的一百八十从最下面出来,然后呢 x 坐标呢?是负的两百三十到两百三十之间。 那重复执行到什么时候呢?到碰到上面的边界,上面边界应该是什么? y 坐标大于谁啊?一百八十吧,或者大于一百七十, 然后这里呢就不是 x 坐标增加了,这里应该是 y 坐标增加, y 坐标增加时。好,我们现在来看一下能不能够实现这两种效果。好,你看 啊,你会发现什么呢?他刚出现 就是容易碰到这个粒子长长的尾巴,对吧?那怎么解决这个问题呢?你可以把这个粒子的尾巴呀给它变短一点,这里因为我们重复执行了十次,你可以给它改成五次。好,再试一下, 这样他的尾巴会变得短一点,对不对? 好,那么大家呢,可以尝试一下啊,从右边也出现箭头,从上边也出现箭头, 那从右边出现箭头呢?就是把它的 x 坐标固定在最右边,然后让它 y, 让它的 x 坐标 要减少,不断减少,往左边挪,到达左边的边界以后,游戏结束。那我如果说从上面出现的箭头呢?把它的高度固定,让他从上往下走,就是歪,坐标降低,然后到达最下面的边界以后呢,让他游戏停止。好,那最后呢,我们再给他来添加一段背景音乐吧, 声音 好了,我们来看一下效果。 好了,我们这节课的内容呢,到此结束,感谢大家的观看,如果这个视频呢,对你有帮助,希望大家可以点赞关注加评论。好,谢谢大家,我们下节课再见。

hello, fellow scratches this is a super short but hopefully helpful tutorial and how to create those nice sprite trail effects in scratch they were recently featured in my boy's video and i got a lot of requests asking how did i do it so without further ado, i'll show you i'll start by creating a forever loop so that scratch cat follows my mouse pointer just like this and now we have something to add a trail to so there are two different approaches to creating trails using clones and stamping each with its own benefits and drawbacks first we'll look at the cloneing technique drop a create clone of myself into the forever loop and whoo we're off right away you can see that we are leaving a trail of cats behind our mouse and the clones are building up fast in fact within no time at all we hit the three hundred clone limit and bam no more clones can be made so the trail stops forming here but not to worry i wasn't envisiging having a trail anywhere near this long anyhow so how do we make it shorter bring in a when i start as clone and a repeat ten loop after about ten repeats we can delete this clone the result of this is that each clone will hang around for about ten ticks of our game and then be deleted that's cool but the effect we are after is for the trail to fade away gradually rather than just stopping all at once, so from the looks category drop in a change effect by block and we want the ghost effect for now set the change amount to also be ten and then run the project and there we go we have achieved a simple sprite trail that's really smart if i just pause the video for a moment i would like to point something out and that is that the trail left behind by a ghost clone is visible through the clone in front of it and this may not bother you, but just remember this for now as i will revisit it later on okay so we have a trail that is ten clones long what if we want longer trails no problem to make it easy create a new custom block naming it fade over and we need an input of frames and why not finish with a label frames and for once we don't want to run without screen refresh that's because this script wants to perform an animation over a number of frames not run in a single quick frame so we'll drop this in as the first block when i start as clone and the following scripts they can move into the new define block nice the idea then is that we can enter how many frames we want our trail to last four let's try twenty five frames so our repeat block can now use the frames input that will be twenty five right now but what about this change ghost effect? how much do we need to change this by to make the fade last for twenty five frames the solution is to consider that a ghost of one hundred is fully ghosted so if we divide that one hundred into frames that is twenty five pieces then that will add backup to one hundred after twenty five repeats perfect run the project yeah that splendid very cool indeed now we can choose exactly how long each trail will be so we did it so why isn't this tutorial over well, because using clones to create trails is not always possible you see we only have three hundred clones to work without any one time and often we want more than just one sprite to have a trail so i'm going to teach you option two and this one uses the pen extension and stamping so let's rewind and go back to our simple forever loop without any cloning insight now click on the extensions button and choose the pen extension brill we can drop an arrays all as the first block in our script just to ensure we begin with a blank pen canvas each time the project runs and try placing a stamp block right after moving the sprite in the forever loop and here we go again we have an endless stamping mouse trail that was easy and this time no clones being created and thus no limit on how long i can go on drawing this trail where we do have a problem is getting this long trail to fade out since once we stamp a sprite it's no longer changeable it's just part of the background well, then we'll need another trick and let me show you something start with an erase all and click that and i'll move scratch cat into the open next up make a new sprite and we'll name it fader i'll make it a bitmap costume and then i can fill it pure white yeah that fully obscure scratch cat for now who is behind this fader sprite some scripts when flag clicked go to zero zero this ensures it fully covers the stage and then go to the back and hide that will bring scratchy interview once more and we want to now click into the scratchcat sprite one and duplicate the stamp block this is what i wanted to show you click stamp and i can now move scratch cat over to the right leaving behind the stamped cat as expected so what happens if we then stamp the white fader sprite right afterwards well, no prizes i'm afraid if you guessed that it would stamp the white costume right over the old stamped cat costume they are now completely erased so that wasn't so useful okay then let me set that backup again stamping the cat and come back to the fader sprite once more this time though we set the ghost effect to fifty before we stamp the background so this time when we click the scripts rather than making the whole stage white we only fade it towards white by half fifty percent white that is cool then once more we can stamp the cat where it is and we get a fresh bright cat back in the fader's bright do the stamp again and not only does the last stamped cat fade away, but the older faded cat fades out even further that's so cool this process we can just simply repeat over and over each click of the fadescript makes the previous stamped graphics fade further and further away until they finally vanish from view i think you get the idea let's put this into practice stick the set goes to effect after the other scripts and bring in a forever loop for our stamp block this will now continually fade away anything that we try to stamp in our case that would be our scratch cat stamped in its own for every loop over here if we run the project then well can you see the trail yes, it's there very subtle, but it is there to make it more prominent all we need to do is change this ghost effect to a larger value approaching one hundred let's try ninety percent wow guys look at that now this is quite a different effect to the clone based trails firstly if i pause it for a second see how each cat is not transparent you can't see the cat behind showing through that makes the trail a lot cleaner and less confused than the clone based one plus we are no longer creating tons of clones and that is a good thing too, but the other difference is that the trail does tend to have this screen burn effect like it fades away, but the last residue hangs around for a lot longer than you might otherwise expect well, that is the way of it and how this method tends to work do try changing the ghost effect to different values to alter the effect it is actually quite fun and you can try each of these methods using clones or stamping and find the one you prefer many scratch projects use either of these, but if you saw my boyd's video i was using the stamping method for my boyd's the reason was that i had way too many clones are ready to afford using more just for the trails so we come to the end of this short tutorial i hope this was helpful to some of you, and that you can just slot that into your projects and have some it works great in so many different projects in games feel free to drop me a comment under the video if you had some success with this love to hear what you've been up to if you enjoy watching my videos please smash that like button and do subscribe to the channel so is not to miss the next exciting tutorial, but that's it for now have a great week ahead and scratch on guys。
