Cocos2d-x 游戏资源 图片 XML TXT等 打包加密 之 解密读取

               

自上一篇  Unity3d 游戏资源打包加密(图片/XML/TXT等) C#编码 (一)   介绍如何打包加密游戏资源已经好几月,却没有详细说明如何在游戏中去读取加密的资源,虽然聪明的程序员看一眼就知道如何逆向编码,但是还是详细说明一下,以作完结。

转自陈里陈外的博客 http://blog.csdn.net/huutu 星环游戏 http://www.thisisgame.com.cn

Cocos2d-X 资源加密与解密

加密只有一篇即可,解密分为两篇,Cocos2d-x 篇 和 Unity3d 篇。

首先,这一篇介绍Cocos2d-x 读取加密的资源。

转自陈里陈外的博客 http://blog.csdn.net/huutu 星环游戏 http://www.thisisgame.com.cn

以下内容需要对Cocos2d-x 稍微深入了解。


XML和文档的读取没啥好讲的,完全不涉及Cocos2d-X。这里不做介绍,如果想了解,请百度C++/C如何读取文件以及各大XML库如何读取XML文件。


下面开始我们的解密之旅。

转自陈里陈外的博客 http://blog.csdn.net/huutu 星环游戏 http://www.thisisgame.com.cn

Cocos2d-x中CCSprite的Create流程

首先我要提一下,在Cocos2d-X中显示一张图片,一般是直接在CCSprite中带图片路径参数去实例化。百分之九十的程序猿们都是这样用的,简单粗暴。但是一旦需要自己对图片进行加密之后,就不能在直接传入图片路径进行实例化,这下该如何是好……

转自陈里陈外的博客 http://blog.csdn.net/huutu 星环游戏 http://www.thisisgame.com.cn

嗯,Cocos2d-X的好处这个时候就提现出来了,开源免费,我们想看啥就看啥,想改啥就改啥。

作为一个合格的程序员一定要具备看源代码的能力。

下面来看一下CCSprite的部分源代码:

class CC_DLL Sprite : public Node, public TextureProtocol{
   public:    static const int INDEX_NOT_INITIALIZED = -1; /// Sprite invalid index on the SpriteBatchNode    /// @{
        /// @name Creators    /**     * Creates an empty sprite without texture. You can call setTexture method subsequently.     *     * @return An autoreleased sprite object.     */    static Sprite* create();    /**     * Creates a sprite with an image filename.     *     * After creation, the rect of sprite will be the size of the image,     * and the offset will be (0,0).     *     * @param   filename A path to image file, e.g., "scene1/monster.png"     * @return  An autoreleased sprite object.     */    static Sprite* create(const std::string& filename);    /**     * Creates a sprite with an image filename and a rect.     *     * @param   filename A path to image file, e.g., "scene1/monster.png"     * @param   rect     A subrect of the image file     * @return  An autoreleased sprite object     */    static Sprite* 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值