Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Flip Sprite — Gideros Forum

Flip Sprite

Tstar_oneTstar_one Member
edited August 2013 in General questions
Hello Guys i need help :D

I want to flip an Sprite . if i do this with setSccaleX(-1) and setScaleY(-1) the Sprite is left from where the object shoud be
so what i have to do ? i use Texture with Region for the Anmimation

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited August 2013
    I think setting anchor point to 0.5, 0.5 should solve that problem, have you tried? :)
  • hm yeah works :D but i need the AnchorPoint at 0 , 0 for Collision an other Functions :S is there any thing i can do ?
  • hmm, what exactly your collision function does? Can't it use Sprite:getBounds() for collision determination?
  • Tstar_oneTstar_one Member
    edited August 2013
    Standard Code from the Forum :)

    function sprite:collision(sprite2)

    --Input (sprite2): another sprite to check for collision detection
    --Return: return true if the rectangles overlap otherwise return false

    -- self bottom < other sprite top
    if self:getY() + self:getHeight() < sprite2:getY() then
    return false
    end
    -- self top > other sprite bottom
    if self:getY() > sprite2:getY() + sprite2:getHeight() then
    return false
    end
    -- self left > other sprite right
    if self:getX() > sprite2:getX() + sprite2:getWidth() then
    return false
    end
    -- self right < other sprite left
    if self:getX() + self:getWidth() < sprite2:getX() then
    return false
    end

    return true
    end


    how can i include code here ? : )
  • you most probably can replace it with this:
    function Sprite:collidesWith(sprite2)
    	local x,y,w,h = self:getBounds(stage)
    	local x2,y2,w2,h2 = sprite2:getBounds(stage)
     
    	return not ((y+h < y2) or (y > y2+h2) or (x > x2+w2) or (x+w < x2))
    end
    And about code inclusion:
    http://members.giderosmobile.com/knowledgebase.php?action=displayarticle&id=41

    ;)

    Likes: Tstar_one

    +1 -1 (+1 / -0 )Share on Facebook
  • Fantastic thank you very much again :D
Sign In or Register to comment.