It looks like you're new here. If you want to get involved, click one of these buttons!
local player = Bitmap.new(Texture.new("player.png",true)) local stone = Bitmap.new(Texture.new("stone.png",true)); stone:setAnchorPoint(.5,.5); stone:setPosition(200,500); stone:setScale(.5) player:setPosition(200,500); player:setScale(.5); stage:addChild(stone); stage:addChild(player) local mainAnchor=Pixel.new(0xff0000,1,10,10)--red main anchor player:addChild(mainAnchor) local secondAnchor=Pixel.new(0x0000ff,1,10,10)--blue secondary anchor player:addChild(secondAnchor) secondAnchor:setPosition(-245,-255) player:setAnchorPoint(.85,.85) player.isClockwise=true player.rotationDir=1 player.speed=2.5 --ON ENTER_FRAME ROTATE PLAYER: local function onEnterFrameFunc() player:setRotation(player:getRotation()+player.rotationDir*player.speed) end stage:addEventListener(Event.ENTER_FRAME, onEnterFrameFunc) --ON TAP: local function onTapFunc(event) local x,y=secondAnchor:localToGlobal(secondAnchor:getAnchorPosition()) if player.isClockwise==true then player.isClockwise=false player:setAnchorPoint(.2,.1) secondAnchor:setPosition(245,255) else player.isClockwise=true player:setAnchorPoint(.85,.85) secondAnchor:setPosition(-245,-255) end player.rotationDir=-player.rotationDir player:setPosition(x,y) pulsePlayerScale() end stage:addEventListener(Event.MOUSE_DOWN, onTapFunc,self) function pulsePlayerScale() local makePlayerSmaller=GTween.new(player, .2, {scaleX=0.4,scaleY=0.4}, {delay = 0, ease = easing.linear, onComplete = function() local makePlayerNormal=GTween.new(player, .2, {scaleX=0.5,scaleY=0.5}, {delay = 0, ease = easing.linear}) end}) end |
Comments
The code is not very well commented but you should be able to decipher how it works with a little effort. Any questions on how it works just ask
Likes: Apollo14, SinisterSoft, talis, MoKaLux