Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Understanding MovieClips- question! — Gideros Forum

Understanding MovieClips- question!

stetsostetso Member
edited May 2017 in General questions
Hello, here I go with another annoying question.

I am trying to chain the movement of some elements together with MovieClip but even in a simple case it does not do what I want. Since there is not :playBackward() function (which would be very handy), I simply have another MovieClip with the reverse coordinates. But somehow it does not do what I want. Can anyone help me understand this problem? Here is a simple code snippet that is already not working:
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)
Hope for some insights as I find the general idea of MovieClips pretty nice but somehow have trouble getting them to work. All the examples floating around are mainly for frame-animations but here I am interested in the tweening functionality :-)

Thanks in advance!

Comments

Sign In or Register to comment.