2012-08-30 15:55:13 +08:00
|
|
|
|
|
|
|
local streak = nil
|
|
|
|
local titleLabel = nil
|
|
|
|
local subtitleLabel = nil
|
|
|
|
|
2013-07-26 13:43:28 +08:00
|
|
|
local s = CCDirector:getInstance():getWinSize()
|
|
|
|
local scheduler = CCDirector:getInstance():getScheduler()
|
2012-08-30 15:55:13 +08:00
|
|
|
|
|
|
|
local firstTick = nil
|
|
|
|
|
|
|
|
local function modeCallback(sender)
|
|
|
|
fastMode = streak:isFastMode()
|
|
|
|
if fastMode == true then
|
|
|
|
streak:setFastMode(false)
|
|
|
|
else
|
|
|
|
streak:setFastMode(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function getBaseLayer()
|
|
|
|
local layer = CCLayer:create()
|
|
|
|
|
|
|
|
local itemMode = CCMenuItemToggle:create(CCMenuItemFont:create("Use High Quality Mode"))
|
|
|
|
itemMode:addSubItem(CCMenuItemFont:create("Use Fast Mode"))
|
2012-09-11 17:13:20 +08:00
|
|
|
itemMode:registerScriptTapHandler(modeCallback)
|
2012-08-30 15:55:13 +08:00
|
|
|
local menuMode = CCMenu:create()
|
|
|
|
menuMode:addChild(itemMode)
|
2013-07-26 13:43:28 +08:00
|
|
|
menuMode:setPosition(CCPoint(s.width / 2, s.height / 4))
|
2012-08-30 15:55:13 +08:00
|
|
|
layer:addChild(menuMode)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.initWithLayer(layer)
|
|
|
|
|
2012-08-30 15:55:13 +08:00
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- MotionStreakTest1
|
|
|
|
-----------------------------------
|
|
|
|
local root = nil
|
|
|
|
local target = nil
|
|
|
|
|
|
|
|
local MotionStreakTest1_entry = nil
|
|
|
|
|
|
|
|
local function MotionStreakTest1_update(dt)
|
|
|
|
if firstTick == true then
|
|
|
|
firstTick = false
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-07-26 13:43:28 +08:00
|
|
|
streak:setPosition(target:convertToWorldSpace(CCPoint(0, 0)))
|
2012-08-30 15:55:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function MotionStreakTest1_onEnterOrExit(tag)
|
2013-03-05 14:46:18 +08:00
|
|
|
if tag == "enter" then
|
2012-08-30 15:55:13 +08:00
|
|
|
MotionStreakTest1_entry = scheduler:scheduleScriptFunc(MotionStreakTest1_update, 0, false)
|
2013-03-05 14:46:18 +08:00
|
|
|
elseif tag == "exit" then
|
2012-08-30 15:55:13 +08:00
|
|
|
scheduler:unscheduleScriptEntry(MotionStreakTest1_entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function MotionStreakTest1()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
|
|
|
root = CCSprite:create(s_pPathR1)
|
|
|
|
layer:addChild(root, 1)
|
2013-07-26 13:43:28 +08:00
|
|
|
root:setPosition(CCPoint(s.width / 2, s.height / 2))
|
2012-08-30 15:55:13 +08:00
|
|
|
|
|
|
|
target = CCSprite:create(s_pPathR1)
|
|
|
|
root:addChild(target)
|
2013-07-26 13:43:28 +08:00
|
|
|
target:setPosition(CCPoint(s.width / 4, 0))
|
2012-08-30 15:55:13 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
streak = CCMotionStreak:create(2, 3, 32, Color3B(0, 255, 0), s_streak)
|
2012-08-30 15:55:13 +08:00
|
|
|
layer:addChild(streak)
|
|
|
|
|
|
|
|
local a1 = CCRotateBy:create(2, 360)
|
|
|
|
|
|
|
|
local action1 = CCRepeatForever:create(a1)
|
2013-07-26 13:43:28 +08:00
|
|
|
local motion = CCMoveBy:create(2, CCPoint(100,0))
|
2012-08-30 15:55:13 +08:00
|
|
|
root:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(motion, motion:reverse())))
|
|
|
|
root:runAction(action1)
|
|
|
|
|
|
|
|
local array = CCArray:create()
|
|
|
|
array:addObject(CCTintTo:create(0.2, 255, 0, 0))
|
|
|
|
array:addObject(CCTintTo:create(0.2, 0, 255, 0))
|
|
|
|
array:addObject(CCTintTo:create(0.2, 0, 0, 255))
|
|
|
|
array:addObject(CCTintTo:create(0.2, 0, 255, 255))
|
|
|
|
array:addObject(CCTintTo:create(0.2, 255, 255, 0))
|
|
|
|
array:addObject(CCTintTo:create(0.2, 255, 255, 255))
|
|
|
|
local colorAction = CCRepeatForever:create(CCSequence:create(array))
|
|
|
|
|
|
|
|
streak:runAction(colorAction)
|
|
|
|
|
|
|
|
firstTick = true
|
|
|
|
layer:registerScriptHandler(MotionStreakTest1_onEnterOrExit)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("MotionStreak test 1")
|
2012-08-30 15:55:13 +08:00
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- MotionStreakTest2
|
|
|
|
-----------------------------------
|
|
|
|
local function MotionStreakTest2()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
streak = CCMotionStreak:create(3, 3, 64, Color3B(255, 255, 255), s_streak)
|
2012-08-30 15:55:13 +08:00
|
|
|
layer:addChild(streak)
|
|
|
|
|
2013-07-26 13:43:28 +08:00
|
|
|
streak:setPosition(CCPoint(s.width / 2, s.height / 2))
|
2012-08-30 15:55:13 +08:00
|
|
|
|
|
|
|
local function onTouchMoved(x, y)
|
|
|
|
if firstTick == true then
|
|
|
|
firstTick = false
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-07-26 13:43:28 +08:00
|
|
|
streak:setPosition(CCPoint(x, y))
|
2012-08-30 15:55:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function onTouch(eventType, x, y)
|
2013-03-01 17:09:42 +08:00
|
|
|
if eventType == "began" then
|
2012-08-30 15:55:13 +08:00
|
|
|
return true
|
2013-03-01 17:09:42 +08:00
|
|
|
elseif eventType == "moved" then
|
2012-08-30 15:55:13 +08:00
|
|
|
return onTouchMoved(x, y)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
firstTick = true
|
|
|
|
layer:setTouchEnabled(true)
|
|
|
|
layer:registerScriptTouchHandler(onTouch)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("MotionStreak test")
|
2012-08-30 15:55:13 +08:00
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- Issue1358
|
|
|
|
-----------------------------------
|
|
|
|
local Issue1358_entry = nil
|
|
|
|
|
|
|
|
local center = nil
|
|
|
|
local fAngle = nil
|
|
|
|
local fRadius = nil
|
|
|
|
|
|
|
|
local function Issue1358_update(dt)
|
|
|
|
if firstTick == true then
|
|
|
|
firstTick = false
|
|
|
|
return
|
|
|
|
end
|
|
|
|
fAngle = fAngle + 1.0
|
|
|
|
streak:setPosition(
|
2013-07-26 13:43:28 +08:00
|
|
|
CCPoint(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius))
|
2012-08-30 15:55:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function Issue1358_onEnterOrExit(tag)
|
2013-03-01 17:09:42 +08:00
|
|
|
if tag == "enter" then
|
2012-08-30 15:55:13 +08:00
|
|
|
Issue1358_entry = scheduler:scheduleScriptFunc(Issue1358_update, 0, false)
|
2013-03-01 17:09:42 +08:00
|
|
|
elseif tag == "exit" then
|
2012-08-30 15:55:13 +08:00
|
|
|
scheduler:unscheduleScriptEntry(Issue1358_entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function Issue1358()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
streak = CCMotionStreak:create(2.0, 1.0, 50.0, Color3B(255, 255, 0), "Images/Icon.png")
|
2012-08-30 15:55:13 +08:00
|
|
|
layer:addChild(streak)
|
|
|
|
|
2013-07-26 13:43:28 +08:00
|
|
|
center = CCPoint(s.width / 2, s.height / 2)
|
2012-08-30 15:55:13 +08:00
|
|
|
fRadius = s.width / 3
|
|
|
|
fAngle = 0
|
|
|
|
|
|
|
|
firstTick = true
|
|
|
|
layer:registerScriptHandler(Issue1358_onEnterOrExit)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("Issue 1358")
|
|
|
|
Helper.subtitleLabel:setString("The tail should use the texture")
|
2012-08-30 15:55:13 +08:00
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
function MotionStreakTest()
|
|
|
|
local scene = CCScene:create()
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.createFunctionTable = {
|
|
|
|
MotionStreakTest1,
|
|
|
|
MotionStreakTest2,
|
|
|
|
Issue1358
|
|
|
|
}
|
|
|
|
|
|
|
|
scene:addChild(MotionStreakTest1())
|
2012-08-30 15:55:13 +08:00
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
return scene
|
|
|
|
end
|