It looks like you're new here. If you want to get involved, click one of these buttons!
function Scene1:init(t) function hexagon (x,y,w,h,c) --xpos,ypos,width,height,color hexsprite = Sprite.new() hexsprite.c = c local hex = Shape.new() hex:setLineStyle(0, 0x000000, 0.5) hex:setFillStyle(Shape.SOLID, c) hex:beginPath() hex:moveTo(0, 0) hex:lineTo(w, 0) hex:lineTo(w+w*0.5, h*0.5) hex:lineTo(w, h) hex:lineTo(0, h) hex:lineTo(-w*0.5, h*0.5) hex:lineTo(0, 0) hex:closePath() hex:endPath() hexsprite:addChild(hex) hexsprite:setPosition(x,y) self:addChild(hexsprite) hexsprite:addEventListener(Event.TOUCHES_MOVE, onTouchesMove,hexsprite) end end |
Comments
But as far as I know, you don't even have to remove it that way. You can simply reload the scene, to itself:
PS:i'm already doing it that way. thx.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Anyway my 2 cents here: You may want to add the following to your removing process as Gideros Seems to hold memory as long as there is ANY reference to that object weak or otherwise.
I don't like setting self to nil, but as you example shows self being used I will use it here, it should work fine as long as you don't inherit the classes cleanup cycle.
Anyway I would setup something like:
*Edited the Init() function since I forgot to add the x,y,w,h,c arguments to it..heh
I did only throw that example together and said something like this in my post so it was implied that it wasn't the only way to do it
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Yeah I was sort of hoping @atilim would finish his Hex/Iso setup with the tile-maps before I needed to use mine, since I am not getting the same performance out of my HexRenderer compared to the tilemap setup in Gideros. There is just something cool about Iso/Hex that makes me always want to make my games in that format--even though my artists HATE making iso tiles heh :P
because inside function Scene1:init self is referenced to a current scene which is Scene1, which is now loaded in SceneManager.
So this scene is added to stage and everything added to this scene will
1. appear on screen when scene appears
2. get removed from screen when scene is removed
Likes: MoKaLux
Since it is done this way, you can add a HexTile to your stage by doing the following since it is all handled internally:
Likes: MoKaLux