. csb files exported using Cocostudio in Lua

Source: Internet
Author: User

1. Load node to scene

The first of these methods

Local scene = cc. Csloader:createnode ("SCENE.CSB")
Self:addchild (Scene)

The second method of

Local scene = Cc.uiloader:load ("MAINSCENE.CSB"): AddTo (self)

2. Strong Turn Wizard Type

Local Sprite = Tolua.cast (object, "CC.") Sprite ")

Cocostudio do the inside of the wizard is Ccsprite (c + +) type can not use SetPosition and some other methods in Lua need to use Tolua.cast (Object,type) for casting type

3. How to use the button differently

Local BTN = Scene:getchildbyname ("button_1")

Btn:addtoucheventlistener (function (Event,type)

if type = = Ccui. Toucheventtype.began Then
Print ("began")
End

if type = = Ccui. Toucheventtype.ended Then
Print ("ended")
End
End

4. Animation (play timeline)

Local timeline = cc. Csloader:createtimeline ("MAINSCENE.CSB");
Scene:runaction (timeline);

Timeline:gotoframeandplay (0,true);

Timeline:setframeeventcallfunc (function (DT)
Print (Dt:getevent ())--frame event
End


This article is from the "10647504" blog, please be sure to keep this source http://10657504.blog.51cto.com/10647504/1714469

. csb files exported using Cocostudio in Lua

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.