Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Rounded Mesh — Gideros Forum

Rounded Mesh

mertocanmertocan Member
edited October 2015 in Code snippets
Hello,

Instead of using shapes you can use rounded mesh.

How to use:
local conf = {
		width = 500,
		height = 800,
		round = 60,
		innerColor = 0xFF0000,
		innerAlpha = 1,
		outerColor = 0x000000,
		outerAlpha = 0
	}
local roundedMesh = RoundedMesh.new(conf)
roundedMesh:setPosition(10,10)
 
stage:addChild(roundedMesh)

Likes: jdbc, pie, misterhup, simwhi

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

Comments

  • piepie Member
    supercool! thanks for sharing :)

    Likes: mertocan

    +1 -1 (+1 / -0 )Share on Facebook
  • With this simple code snippet you can easily create 3d runner game :)
    application:setBackgroundColor(0xFF0000)
    local conf = {
    		width = application:getLogicalWidth(),
    		height = application:getLogicalHeight(),
    		round = 60,
    		innerColor = 0x000000,
    		innerAlpha = 1,
    		outerColor = 0x000000,
    		outerAlpha = 0
    	}
    local room = RoundedMesh.new(conf)
    stage:addChild(room)
     
    local conf = {
    		width = 2,
    		height = 2,
    		round = 0,
    		innerColor = 0x00FF00,
    		innerAlpha = 1,
    		outerColor = 0x00FF00,
    		outerAlpha = 0
    	}
    local box = RoundedMesh.new(conf)
    box:setPosition((application:getLogicalWidth()-box:getWidth())/2,(application:getLogicalHeight()-box:getHeight())/2)
    stage:addChild(box)
     
    local function EnterFrame(event)
     
    		box:setPosition((application:getLogicalWidth()-box:getWidth())/2,(application:getLogicalHeight()-box:getHeight())/2+(event.frameCount))
    		box:setScale(box:getScale()+0.2)
     
    	if box:getY() >= application:getLogicalHeight() then
    		box:removeFromParent()
    		stage:removeEventListener(Event.ENTER_FRAME,EnterFrame)
    	end
    end
     
    stage:addEventListener(Event.ENTER_FRAME,EnterFrame)

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Thanks for sharing, but has it some benefit vs using shapes ? Is it more efficient ? Because that resulting mesh will be similar to what Gideros does internally when using Shape. Just wondering :)

    Vector graphics that will come along HTML5 will handle curves natively through dedicated shaders and will be much faster, but that's another story.
  • Infinite loop!
    My Gideros games: www.totebo.com
  • Ahhh there is a glitch in the matrix :D
  • When I go to the link above it takes me here again. I'm on Chrome on my mobile.
    My Gideros games: www.totebo.com
Sign In or Register to comment.