Cocos2d-x3.2下Lua,UserDefault、Texture的使用

原文地址:http://blog.csdn.net/qqmcy/article/details/37962013


//
//  
//  
//
//  Created by 杜甲 on 14-7-16.
//
//

require "Cocos2d"


 function Shaky3DDemo(t)
        return cc.Shaky3D:create(t,cc.size(15,10),5,false)
end





local Sprite1 = {}
Sprite1.__index = Sprite1
setmetatable(Sprite1,cc.Sprite)


local mLayer = {}
mLayer.__index = mLayer
function mLayer.initlayer()
    pLayer = cc.Layer:create()
    local sprite = cc.Sprite:create("res/dog.png")
    sprite:setPosition(300,200)
    pLayer:addChild(sprite)
    
    --赋值
   cc.UserDefault:getInstance():setStringForKey("name","xiaonan")
   --取值
   local ret = cc.UserDefault:getInstance():getStringForKey("name")
   --打印UserDefault中取出的值
   print("name is ",ret)
   --打印Texture的信息
   print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
   
   
	return pLayer
end




local helloScene = {}
function helloScene.create()
    local scene = cc.Scene:create()

    local layer2 = mLayer.initlayer()
    scene:addChild(layer2)
    return scene
end



cc.Director:getInstance():runWithScene(helloScene.create())






你可能感兴趣的:(Cocos2d-x3.2下Lua,UserDefault、Texture的使用)