最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么我的蛇只能左右 ,而不能上下移動(dòng),運(yùn)行沒(méi)有報(bào)錯(cuò),求大神解答

local Snake = require "app.Snake"

local MainScene = class("MainScene", function()

? ? return display.newScene("MainScene")

end)


local cMoveSpeed = 0.3


function MainScene:onEnter()

self.Snake = Snake.new(self)


self:ProcessInput()



local tick = function()

self.Snake:Update()

end


cc.Director:getInstance():getScheduler():scheduleScriptFunc(tick,cMoveSpeed,false)


end

-------------------------------------------------------------

local function vector2Dir(x,y)


if math.abs(x) > math.abs(y) then

if x < 0 then

return "left"

else

return "right"

end


else


if y < 0 then

return "up"

else

return "down"

end

end


end

-------------------------------------------------------

function MainScene:ProcessInput()


local function onTouchBegan(touch,event)


local location = touch:getLocation()

local visibleSize = cc.Director:getInstance():getVisibleSize()

local origin = cc.Director:getInstance():getVisibleOrigin()


local finalX = location.x - (origin.x + visibleSize.width/2)

local finalY = location.y - (origin.y + visibleSize.height/2)


local dir = vector2Dir(finalX,finalY)

self.Snake:SetDir(dir)

end

local listener = cc.EventListenerTouchOneByOne:create()

listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)


local eventDispatcher = self:getEventDispatcher()

eventDispatcher:addEventListenerWithSceneGraphPriority(listener,self)



end


正在回答

1 回答

坐標(biāo)判斷的有點(diǎn)問(wèn)題

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么我的蛇只能左右 ,而不能上下移動(dòng),運(yùn)行沒(méi)有報(bào)錯(cuò),求大神解答

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)