简体   繁体   English

如何使用cocos2d-x将子画面分解为像素?

[英]how to dissolve a sprite into pixels using cocos2d-x?

i have a LOGO image and i want to dissolve it into small square pixels images from down to top of the Logo image with fade in action and Logo remove completely then my game start. 我有一个LOGO图像,我希望将其从Logo图像的顶部向下溶解为小正方形像素图像,并逐渐淡化,然后将Logo完全移除,然后开始游戏。 how can i do it in cocos2d-x v3 using C++ coding or any other way?Thanks in advance. 我如何使用C ++编码或任何其他方式在cocos2d-x v3中做到这一点?

There's nothing in this code just to have permission to ask question i made it just like that. 这段代码中没有什么内容可以允许我提出这样的问题。

CCAction *fadeIn = [CCFadeTo actionWithDuration:0.5 opacity:0.5];
CCAction *fadeOut = [CCFadeTo actionWithDuration:0.5 opacity:1.0];
CCSequence *pulseSequence = [CCSequence actions:[fadeIn copy],[fadeOut copy], nil];

I think your only method here to TRULY have the logo dissolve into pixels, will be brute force, which will mean rebuilding the logo one pixel at a time by adding single pixels sprites onto a layer, so instead of logo.png you have a ton of whitepixel.png redpixel.png etc, then send them into action. 我认为您要真正使徽标溶解为像素的唯一方法是蛮力,这意味着通过在图层上添加单个像素精灵来一次将徽标重建一个像素,因此您需要一吨来代替logo.png whitepixel.png redpixel.png等,然后将其发送给行动。 Depending on how fast it dissolves, this would work (although rebuilding the logo with pixel art will take a long time, i'd recommend doing it with a pixel matrix and write a function to place the sprites). 取决于溶解的速度,此方法将起作用(尽管用像素图重建徽标会花费很长时间,但我建议使用像素矩阵来完成它并编写一个放置小精灵的函数)。

Alternatively, you can fake it by simply slowly covering/obscuring/fading the sprite top to bottom and spitting particles out along the wipe line. 另外,您可以伪造它,只需将精灵顶部到底部缓慢覆盖/遮盖/淡化,然后沿擦拭线将粒子撒掉即可。 If you want it to un-print slowly one line at a time, you'd need 2 obscuring images, one to cover vertically as you go line by line, one to be wiping the next line horizontally. 如果您希望它一次缓慢地取消打印一行,则需要2张模糊的图像,一张逐行覆盖垂直,另一张则水平擦拭下一行。 This would be much easier to demonstrate via video, add my Skype reduxde if you want and I can show you with some construction paper. 通过视频进行演示将更加容易,如果需要,可以添加我的Skype reduxde,并且我可以向您展示一些构造文件。

I'm bad with particles, but as long as you're picking particles that match the colors in the logo, most peoples eyes won't be able to track it to realize the pixels aren't a 1:1 match up. 我对粒子很不好,但是只要您选择与徽标中的颜色匹配的粒子,大多数人的眼睛就无法跟踪它以意识到像素不是1:1匹配。

For a logo that's say 160 by 100 pixels though, you're talking 16,000 sprites by the brute force method, which will undoubtedly lag out your devices (I've managed to get about 700-800 sprites in motion before until the engine chugs). 对于说是160 x 100像素的徽标,您正在通过蛮力方法谈论16,000个精灵,这无疑会落后于您的设备(在引擎突然跳动之前,我设法使700-800个精灵处于运动状态) 。

Probably your best bet would be to hire a graphic artist and do this as an animation using a sequence of photos (which would be choppy compared to a true dissolve). 最好的选择也许是雇用一名图形艺术家,并使用一系列照片作为动画来做这件事(与真正的溶解相比,这会显得比较不稳定)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM