Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Does Gideros support primitive shapes? — Gideros Forum

Does Gideros support primitive shapes?

ondesicondesic Member
edited July 2012 in General questions
I need to be able to draw a single line. Then from time to time I need to change it's length and position. Is this possible with gideros? I have been looking through the docs of gideros and I found a shape class, but it doesn't seem to do what I want. I couldn't find any tutorials on this either. Any help would be appreciated :)

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited July 2012
    You need to use shape class and draw the shape you want.
    After that either scale it (bad idea), or clear it and draw the shape again (good idea) :)

    Shape API is quite straight forward. begin drawing using beginPath method, end drawing using endPath method. use moveTo for first point, and then lineTo for other points.
    If you need only one line, then set line width, and color using setLineStyle method.

    Clear shape to draw again, using clear method. That's it
    local line = Shape.new()
    line:setLineStyle(5, 0x000000, 1)
    line:beginPath()
    line:moveTo(0,0)
    line:lineTo(100, 0) --for horizontal line
    line:endPath()
     
    --add it to stage
    stage:addChild(line)
    --position where you want it to be
    line:setPosition(100, 100)
  • Thanks. I guess it is a little more complicated than:
    local line = DrawLine(x,y,width, color)

    It would be nice to have a simplified class for this, though I suppose I could just create a function to do it (maybe)
  • ar2rsawseenar2rsawseen Maintainer
    Believe me it can't get any simpler than this and still stay more of a generic class, or @atilim would end up writing hundreds of different classes, shorthanded for different purposes. And believe me, we would not want that.
    Better wrap it up your self in a function :)
  • @ar2rsawseen totally agree, it's easy enough to write your own DrawLine function with the shape class. I did the same for HexTiles :) The Shape class is nice, I only wish it would let me antialias the final texture.
    ThumbHurt Games / FB: ThumbHurt Games / FB: Eli/Teranth | Skype: teranth37
  • same here +1 for antialising
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Good to hear I am not the only one heh, I would have switched my games over to full SVG graphics if it would just let me anti-alias the shape, but I can't have it end up jagged etc.

    It would be great to use SVG since then I can scale the graphics at run-time and not have to deal with multiple graphic sizes.
    ThumbHurt Games / FB: ThumbHurt Games / FB: Eli/Teranth | Skype: teranth37
Sign In or Register to comment.