如何制作像cookie clicker一样的浮动文本onclick?
当点击 cookie clicker 中的“big cookie”时,会出现一个弹出窗口,显示您获得了多少 cookie(此图像中为 +276.341 septillion),该窗口缓慢向上移动并消失 出去。
我想在我的游戏中实现类似的功能,我成功地用css动画制作了向上和淡出部分,但是,这些数字会同时出现多个,那么我如何克隆元素呢?如何让这些显示在光标位置?
When clicking the "big cookie" in cookie clicker, there is a popup showing how many cookies you earned (+276.341 septillion in this image), which slowly moves upward and fades out.
I wanted to implement a similar feature in my game, I sucessfully made the moving up and fading out part with css animations, however, there will be more than one of these numbers showing up at once, so how do I clone elements? And how do I make these show up at the cursor position?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你正在使用什么技术,所以这里是如何使用普通 HTML 和 JS 来做到这一点。
你说你已经制作了 HTML & CSS,因此将您的 HTML 转换为模板
现在在您的 javascript 中,在每次单击时克隆模板
I don't know what technologies you are using so here is how to do it with vanilla HTML and JS.
You say you already made the HTML & CSS, so turn your HTML into a template
Now in your javascript, clone the template on each click