Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Shape Editor — Gideros Forum

Shape Editor

sslivkasslivka Member
edited May 2013 in General questions
Forgive Google Translate for my English.
The situation: there is a sprite image on it - how do you know that I clicked on the visible part of the picture, and not by its transparent area? Sprite: hitTestPoint (x, y) - will not work. It is necessary to tie to the bitmap array with polygon vertices, which determines the visible part of the picture, and the function of checking whether the point of the plane of the polygon. This function is described here: http://www.giderosmobile.com/forum/discussion/comment/775#Comment_775
And to make it easier to make a polygon that defines the visible part of the picture, did such tool:
- Instead image.png - add existing fails to correct you picture;
- Run the project and start the mouse draw path picture;
- If clicked is not there - grab this point and drag to the right place;
- If the point you want to delete - doubleclick on it;
- If you go to add a point not at the end, and in the middle, - highlight by clicking the place in front of which should be a new window, and then click there where it should appear.
I wanted to add triangulation to Box2D, but the algorithm Feronato (http://www.emanueleferonato.com/2012/06/27/polygon-triangulation-decomposition-of-a-polygon-into-triangles-with-as3/) is unstable - threw.
image

Likes: AhBadiane, Scouser

+1 -1 (+2 / -0 )Share on Facebook

Comments

  • Great, I need this function
    thank you @sslivka
    AhBadiane
  • @sslivka: Well done, great addition to Gideros. I have a suggestion that I think would make it a little easier to use.

    At line 105 in main.lua, change
    table.insert(vertices, pos, Bitmap.new(texturePack:getTextureRegion("unselected")))
    to
    table.insert(vertices, pos, Bitmap.new(texturePack:getTextureRegion("selected")))
    vertices[pos].isFocus = true
    vertices[i]:setTextureRegion(texturePack:getTextureRegion("unselected"))
    vertices[i].isFocus = false
    To make the last inserted point the one that is selected. This will allow the developer / artist to make their shapes easier. I have attached the project with the changes in for you to check out.
    rar
    rar
    Shape Editor.rar
    31K
  • Just made a couple of changes in the button 'click' handler function.
     -- the 6 is because there are 5 elements on the stage that need to be there.
     for i=stage:getNumChildren, 6, -1 do
      stage:removeChildAt(i)
     end 
     vertices = {}
    This code clears up the canvas to start again if you have to.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • OZAppsOZApps Guru
    edited May 2013
    ..looking at setting the last co-ordinate to one of the vertices rather than 0,0 which causes a line to be drawn from the top left corner of the stage after a point is deleted (double clicked) or moved.

    Note: Double Tap visually removes a vertex but not from the table. and that causes multiple entries in the vertices table. Perhaps because of the fact that a point is added after the selected vertex under the -- добавляем новую вершину loop.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • sslivkasslivka Member
    @OZApps, Coordinates of the vertices are considered not as a result of (0.0) scene, and from the upper left corner of the image to which clings to a form. Black border is the domain of the original image for this area to determine the top meaningless. When you delete a point it will be deleted from the table and visually:
    main.lua - line 65
    [lua]
    if (os.time () - t0) == 0 and vertices [i]. isFocus then
    stage: removeChild (vertices [i])
    table.remove (vertices, i)
    [/ lua]
  • That's what I get at times. It is 0,0 on the player, which is mostly -192, -40 on the image.
    Screen Shot 2013-05-16 at 11.36.41 AM.png
    645 x 351 - 58K
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
Sign In or Register to comment.