Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to do a single image animation — Gideros Forum

How to do a single image animation

Sush19Sush19 Member
edited April 2014 in General questions
I want to do an animation with a single image as shown in this video: I've included the bone image
http://www.screenr.com/I4dN
Parabolic Tween
BoneSample.png
289 x 108 - 6K

Comments

  • Basically you can create arc with below function to move this bone. you need to tweak it little
    function drawArc(xc,yc,xradius,yradius,startAngle,endAngle,isFill)
    	if yradius == nil then
    		yradius = xradius
    	end
    	if startAngle == nil then
    		startAngle = 0
    	end
    	if endAngle == nil then
    		endAngle = 360
    	end
    	if isFill == nil then
    		isFill = true
    	end
    	local shape = Shape.new()
    	if isFill then
    		shape:setFillStyle(Shape.SOLID, 0xffffff, 0.5)
    	else
    		shape:setLineStyle(3, 0x000000)
    	end
    	shape:beginPath()
    	for i=startAngle,endAngle do
    		if i==1 then
    			shape:moveTo(math.sin(math.rad(i)) * xradius, math.cos(math.rad(i)) * yradius)
    		else
    			shape:lineTo(math.sin(math.rad(i)) * xradius, math.cos(math.rad(i)) * yradius)
    		end
    	end
    	if isFill then
    		shape:closePath()
    	end
    	shape:endPath()
    	shape:setPosition(xc,yc)
    	return shape
    end
    :)
  • Hi, Thank you for the reply, I didn't get how to implement it with the image, I don't want that line shown in the video, it was just for illustration. The concept is just like I'm throwing a bone to a dog in Parabolic angle. I can do it using MovieClip but I don't want to use it, I just want to know how to achieve this with single image.

    The bone should move in Parabolic angle with 360 degree rotation, some thing like this:
    BoneAni.png
    116 x 226 - 10K
  • DiscipleDisciple Member
    Accepted Answer
    You just have to make a Sprite and make it move through coding. I made an example:
    local bone = Sprite.new()
    local boneImg = Bitmap.new(Texture.new("BoneSample.png"))
    stage:addChild(bone)
    bone:addChild(boneImg)
    boneImg:setAnchorPoint(0.5, 0.5)
    local grav = -15
    local velx = -3
    local rotvel = -3
    local x = 300
    local y = 400
    local rotation = 0
     
     
    function enterFrame ()
    	grav = grav + 0.3
    	x = x + velx
    	y = y + grav
    	rotation = rotation + rotvel
    	bone:setRotation(rotation)
    	bone:setPosition(x, y)
    end
     
    stage:addEventListener(Event.ENTER_FRAME, enterFrame)
    zip
    zip
    Bone Example.zip
    7K
Sign In or Register to comment.