@Scouser, yes there was an idea to provide also setting alpha for shadows, but I encountered a problem discussed in first post, which I did not solve yet:
Show child behind the parent or not inherit alpha Explanation:
Shadows for TextField is implemented making real textfield act as shadow and it's child as real displayable text, making shadow the parent of real text. This gives two disadvantages, a little more complex to implement, but we handled that, and inability to set alpha transparency to shadow, because real text automatically inherits it. So what could be the solution to this: making shadow child of a real text, but make it appear under real text, not on top of it or do not let real text inherit alpha from parent. I thought of other possible implementations, as adding shadow as a brother of textfield (setting it before textfield) under same parent, but this raised many unwanted scenarios, where original textfield changes z-index, or parent, which would require a lot of additional code to bypass this scenarios. But I'll hear any ideas you might have
@moopf thank you for finding, I always seem to forget to put recall on anchoring
BTW I'm working on a game right now, using GiderosCodingEasy so will implement some fixes I found from that and also some additions (mostly to box2d wrapper)
createText( x, y, text, fontName, fontSize, hasShadow )
this could then create a group with two textFields, one which is the shadow with the relevant alpha and the one on the top the actual textField. While there would be no more direct access to the textField as the returned object is a group. That is where the setText can be overridden on the group to set the text for both the shadow and the text.
Just another way to deal with it ( creates an extra object that's all, but can offer more flexibility )
Yes I had the idea of another container, I can't really remember what was the scenario were this was a very bad case. But basically it means that TextField object is not a textfield object any more, but for example sprite called TextField object having two children and all of it's methods should be overriden.
Well if I won't remember why I didn't go with that in the first place, I will try to re-implement it using grouping element
Hi @ar2rsawseen, I'm just trying out the sprite transforms and I couldn't get the param skewX etc. to be accepted. Have change the Sprite.transform definition to:
And that seems to have sorted it. It's because you're testing for keys in the set routine, and the way it was by default they were being set as values instead.
Edit: skews also mess up anchor points as well
Edit Edit: In fact skews are completely messing up positions.
Edit Edit Edit: There are no getters either for the values you set.
One thing that I recollect is the anchor points can be scaled and applied for objects, but when rotating they do not work very well, any thing on that?
Hi @ar2rsawseen, I'm just starting to use GiderosCodingEasy in anger in a project and I've come across this. Around line 652 I have had to modify the TexturePack.new override as follows:
localfunction defExt(path, ext)local found, len, remainder =string.find(path, "^(.*)%.[^%.]*$")if found thenreturn path
elsereturn path .. "." .. ext
endend
TexturePack._new = TexturePack.new
function TexturePack.new(...)local pack
local arg={...}iftype(arg[1])=="string"thenlocal txt=defExt(arg[1], "txt")local png=defExt(arg[2]or arg[1], "png")
pack = TexturePack._new(txt, png)else
pack = TexturePack._new(...)endreturn pack
end
As I see it there are two issues:
1) I was getting an error "attempt to index local 'arg' (a nil value)". This may be related to this article on StackOverflow. At any rate, including the line "local arg={...}" seems to fix it.
2) I think your assumption that if a filename is supplied then it will not have an extension is rather restrictive (certainly it caught my existing code out in a number of places). Hence I have added the defExt() function to only append an extension to the filename(s) if one has not already been supplied. There may be some other situations in GiderosCodingEasy where this may be useful too.
Oh my god, I have so much things to do with GiderosCodingEasy and they keep piling up.
But I have a very good excuse. My friend (in attempt to persuade me to buy one) gave me a Kinect to try for couple of weeks. And I couldn't have done any work at home since.
But don't worry, it will be over soon
@bowerandy completely agree, first attempt was a quick and dirty one. But don't understand why arg does not work anymore, did Gideros upgrade Lua version or something like that? Will need to apply solution in many places, thanks again @bowerandy
That is a great site, specially since from there I got to know of Source Filmmaker from Valve, a free tool for creating 3D models and animations. Maybe once we get 3D capabilities in Gideros, this would be handy.
Well I don't really like dancing, I mostly play Kinect Sports, Football seems to be my favorite. Also love Fitness. But my wife plays Dance Central a lot.
That is a great site, specially since from there I got to know of Source Filmmaker from Valve, a free tool for creating 3D models and animations. Maybe once we get 3D capabilities in Gideros, this would be handy.
OFFTOPIC: Well, I already have a copy of that motion capture stuff and I've been using it with two Kinects to capture animations. Works quite well, even detecting the motions that would be in "shadow" when just using a single Kinect. Indeed, I have an interesting idea for a game to make use of this when @atilim can get around to implementing Asynchronous Loading of Textures (ahem!!).
@ar2rsawseen, have you finished playing with that Kinect yet?
I've found a couple more changes that I think are needed in GiderosCodingEasy.
I'm currently working on a gradient fill for shapes and to do it I need to be able to replay the points that are already recorded inside an existing shape. I see that you currently attempt to keep a record of all the points in the _allPoints array. However, I don't think this is being updated correctly because you don't bump the index. Currently the array is always empty. Here is the change I think is required:
Shape._moveTo = Shape.moveTo
function Shape:moveTo(x,y)
self:_moveTo(x, y)
self._lastPoint ={ x, y }
self._allPoints[#self._allPoints+1]= x
self._allPoints[#self._allPoints+1]= y
return self
end
Shape._lineTo = Shape.lineTo
function Shape:lineTo(x,y)
self:_lineTo(x, y)
self._lastPoint ={ x, y }
self._allPoints[#self._allPoints+1]= x
self._allPoints[#self._allPoints+1]= y
return self
end
With that done the Shape:drawPoly() function needs to modified to make use of the array that is returned from Shape:getPoints():
function Shape:drawPoly(points)local drawOp=self.moveTo
self:beginPath()for i =1, #points, 2do
drawOp(self, points[i], points[i+1])
drawOp=self.lineTo
end
self:closePath()
self:endPath()return self
end
Note I think there was also a bug in the original implementation because you did a lineTo() the first point. I have modified this to do a moveTo().
In order to accept this format of point array then Shape:drawRectangle(0 needs modifying:
Finally, you are not recording the interpolated points inside Shape:quadraticCurveTo() and Shape:bezierCurveTo() because you go direct to the original _lineTo methods. Hence I think these should be:
function Shape:quadraticCurveTo(cpx, cpy, x, y, mu)if self._lastPoint thenlocal points = quadraticCurve(self._lastPoint[1], self._lastPoint[2], cpx, cpy, x, y, mu)for i =1, #points, 2do
self:lineTo(points[i],points[i+1])endend
self._lastPoint ={ x, y }return self
endfunction Shape:bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, mu)if self._lastPoint thenlocal inc = mu or0.1-- need a better defaultfor i =0,1,inc dolocal p = bezier4({ x=self._lastPoint[1], y=self._lastPoint[2]},
{ x=cp1x, y=cp1y },
{ x=cp2x, y=cp2y },
{ x=x, y=y },
i)
self:lineTo(p.x,p.y)endend
self._lastPoint ={ x, y }return self
end
There are quite a few changes here so I've attached a copy of my current GiderosCodingEasy.lua to this post.
When I first saw that you were recording all of the shape points I was a little dubious because if the potential memory issue for complex shape drawing. The fact that the existing implementation doesn't work makes me wonder whether you perhaps had a change of heart over this. I'd be grateful if you could let me know whether the above fixes fit with what you intended since, if not, it will impact how I implement these gradient fills I'm working on.
@ar2rsawseen, here's another couple of minor fixes. You aren't currently passing the parameters to Sound:play() on to the overridden method. Around line 1092:
And @bowerandy is postToInputQueue still needed after latest update to Gideros? And I've implemented everything for internal point storage for Shape, I was also in doubt of how it will turn out, mainly would used memory be justified for the enhancements it could provide, but figured if you manage to do gradient Shapes then it certainly will
And @bowerandy is postToInputQueue still needed after latest update to Gideros? And I've implemented everything for internal point storage for Shape, I was also in doubt of how it will turn out, mainly would used memory be justified for the enhancements it could provide, but figured if you manage to do gradient Shapes then it certainly will
Hi @ar2rsawseen, the latest Gideros release fixes the bug where I demonstrated a use for a "postToInputQueue" feature so it isn't needed to get around that problem now. However, I still feel it is a useful facility but, if no one else has yet come across a need for such a thing, then it might be best to leave it out for the time being.
@bowerandy sure, could you elaborate on other situations where postToInputQueue would be useful? Maybe there some new interesting approach or design pattern I'm not aware of.
Based on the latest Sound API update, I wanted a way to control the number of loops a sound is played. I would like to suggest the following to be reviewed/included to GiderosCodingEasy :
function Sound:playWithLoopCount(startTime, nbLoops)
nbLoops = nbLoops or1local soundLength = self:getLength()local channel = self:play(startTime, true)-- loop infinitely-- set looping as false after (loops - 0.5) count
Timer.delayedCall((nbLoops - 0.5)* soundLength, function() channel:setLooping(false)end)return channel
end
Originated from my post here and a bit of precious help from Sir @atilim
Hi guys, newbie in gideros but try this fantastic stuff (OOP addicted :-) Since the last update, i get an error in my code and think i do something wrong, which actually was valid till the last gideros releases: I have a box class which is mainly a shape. .. Box = Core.class( Shape ) function Box:init( config ) .. end
I thougt that, inheriting from the shape class, function Shape.new() should be first called and then my Box:init function. So did my app behave before my gideros update. But the code now crashes because moveto fct. misses _allPoint var of the GiderosCodingEasy definition.
What i ma i doing wrong ? Didi something changed on the object creation in the new gideros version ? Thanks in advance, yarnee
@yarnee, yes something changed in 2012.9.10 and to use GiderosCodingEasy you'll need an update (hint, hint @ar2rsawseen). Basically, it is no longer allowable to override .new() if a class is later subclassed. The solution is to override .__new() instead.
I'm attaching my current version of GiderosCodingEasy. There are some other changes in there as well; some are enhancements and others are bug fixes. @ar2rsawseen, would you care to review my changes and see which ones you'd like to include in the GitHub repo?
Comments
Show child behind the parent or not inherit alpha
Explanation: @moopf thank you for finding, I always seem to forget to put recall on anchoring
BTW I'm working on a game right now, using GiderosCodingEasy so will implement some fixes I found from that and also some additions (mostly to box2d wrapper)
Hopefully this all will be done on weekend
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Just another way to deal with it ( creates an extra object that's all, but can offer more flexibility )
my $ 0.02
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
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
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
But basically it means that TextField object is not a textfield object any more, but for example sprite called TextField object having two children and all of it's methods should be overriden.
Well if I won't remember why I didn't go with that in the first place, I will try to re-implement it using grouping element
Edit: skews also mess up anchor points as well
Edit Edit: In fact skews are completely messing up positions.
Edit Edit Edit: There are no getters either for the values you set.
Will try to experiment with skewing more
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
1) I was getting an error "attempt to index local 'arg' (a nil value)". This may be related to this article on StackOverflow. At any rate, including the line "local arg={...}" seems to fix it.
2) I think your assumption that if a filename is supplied then it will not have an extension is rather restrictive (certainly it caught my existing code out in a number of places). Hence I have added the defExt() function to only append an extension to the filename(s) if one has not already been supplied. There may be some other situations in GiderosCodingEasy where this may be useful too.
Let me know if you agree with these fixes.
best regards
But I have a very good excuse. My friend (in attempt to persuade me to buy one) gave me a Kinect to try for couple of weeks. And I couldn't have done any work at home since.
But don't worry, it will be over soon
@bowerandy completely agree, first attempt was a quick and dirty one.
But don't understand why arg does not work anymore, did Gideros upgrade Lua version or something like that? Will need to apply solution in many places, thanks again @bowerandy
http://ipisoft.com/products.php
best regards
ok I'll wait till I give kinect back
You have to dance with Dance Central at least once, to PokerFace...
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
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
best regards
Likes: OZApps
I've found a couple more changes that I think are needed in GiderosCodingEasy.
I'm currently working on a gradient fill for shapes and to do it I need to be able to replay the points that are already recorded inside an existing shape. I see that you currently attempt to keep a record of all the points in the _allPoints array. However, I don't think this is being updated correctly because you don't bump the index. Currently the array is always empty. Here is the change I think is required:
In order to accept this format of point array then Shape:drawRectangle(0 needs modifying:
When I first saw that you were recording all of the shape points I was a little dubious because if the potential memory issue for complex shape drawing. The fact that the existing implementation doesn't work makes me wonder whether you perhaps had a change of heart over this. I'd be grateful if you could let me know whether the above fixes fit with what you intended since, if not, it will impact how I implement these gradient fills I'm working on.
best regards
Well back to everyday life, will try to get on this one next week
And @bowerandy is postToInputQueue still needed after latest update to Gideros?
And I've implemented everything for internal point storage for Shape, I was also in doubt of how it will turn out, mainly would used memory be justified for the enhancements it could provide, but figured if you manage to do gradient Shapes then it certainly will
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
best regards
Maybe there some new interesting approach or design pattern I'm not aware of.
I would like to suggest the following to be reviewed/included to GiderosCodingEasy :
Since the last update, i get an error in my code and think i do something wrong, which actually was valid till the last gideros releases: I have a box class which is mainly a shape.
..
Box = Core.class( Shape )
function Box:init( config )
..
end
I thougt that, inheriting from the shape class, function Shape.new() should be first called and then my Box:init function. So did my app behave before my gideros update.
But the code now crashes because moveto fct. misses _allPoint var of the GiderosCodingEasy definition.
What i ma i doing wrong ?
Didi something changed on the object creation in the new gideros version ?
Thanks in advance,
yarnee
I'm attaching my current version of GiderosCodingEasy. There are some other changes in there as well; some are enhancements and others are bug fixes. @ar2rsawseen, would you care to review my changes and see which ones you'd like to include in the GitHub repo?
best regards
Likes: vitalitymobile, yarnee