It looks like you're new here. If you want to get involved, click one of these buttons!
application:setLogicalDimensions(160,144) application:setBackgroundColor(0x222220) local state = "up" local p1 = Pixel.new(0xF17370) p1:setAnchorPoint(0.5,0.5) p1:setWidth(10) p1:setHeight(10) p1:setPosition(80,20) stage:addChild(p1) local mc1 = MovieClip.new{ -- move the square down {1,50,p1,{ y= {p1:getY(), 80, "inOutBack"}}} } mc1:stop() local mc2 = MovieClip.new{ -- move it up again {1,50,p1,{ y= {p1:getY(), 20, "inOutBack"}}} } mc2:stop() stage:addEventListener(Event.KEY_DOWN, function(ev) if ev.keyCode == KeyCode.X then print(state) if state == "up" then mc1:gotoAndPlay(1) state="down" elseif state == "down" then mc2:gotoAndPlay(1) state = "up" end end end) |
Comments
so your error is that you regard the mc inits as functions whereas they are stored as values.
so if you change p1:getY() to 20 and the second occurrence to 80, it will work fine.
Likes: stetso
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Maybe we can persuade @hgy29 or @john26 to look into implementing a reverse function. I have seen a few other comments in the forum looking for something like that. Although I dont know the complexity involved... O:-)
Likes: antix
@antix: that's not quite true, MovieClip acts on sprites only, the coder is responsible for creating the sprites. MovieClip is more a tweening system than a way to display animations I would say, despite its name.
Likes: stetso, SinisterSoft