It looks like you're new here. If you want to get involved, click one of these buttons!
function Sprite:ignoreTouchHandler(event) -- Simple handler to ignore touches on a sprite. This blocks touches -- from other objects below it. if self:hitTestPoint(event.touch.x, event.touch.y) then event:stopPropagation() end end function Sprite:ignoreMouseHandler(event) -- Simple handler to ignore mouse events on a sprite. This blocks mouse events -- from other objects below it. if self:hitTestPoint(event.x, event.y) then event:stopPropagation() end end function Sprite:ignoreTouches(event) -- Tell a sprite to ignore (and block) all mouse and touch events self:addEventListener(Event.MOUSE_DOWN, self.ignoreMouseHandler, self) self:addEventListener(Event.TOUCHES_BEGIN, self.ignoreTouchHandler, self) end |
function TextField:sayPhrase(newPhraseString) local function addSymbol() for i=1, #newPhraseString do self:setText(utf8.sub(newPhraseString,1,i)) Core.yield(0.02) end end Core.asyncCall(addSymbol) end |
Likes: MoKaLux
Comments
function Balloon = Core.class(TextField)
function Ballon:sayphrase ()...
Forgive me i am on mobile
Likes: oleg, MoKaLux, Apollo14
Likes: MoKaLux, Apollo14
You have another way to obtain the same, that is to create a direct subclass (Sprite in this case) by which each classes in your app (MyGameSprite, or TouchBlockingSprite, or even TouchBlockingSprite inheriting from MyGameSprite) will inherit wanted behavior.
Each of them have strengths and weaknesses.
The first represents a shortcut in the way you avoid the creation of a new class. It can be also useful if you want to change something "not complex" to an existing code.
I would prefer the second solution because gives you a greater level of flexibility, and responsibilities separation. What in fact if you need (to implement your behavior) to do an "override" of some existing behaviors of the superclass?
What if you need multiple objects do different things? Your risk is to finish with huge superclasses that does everything.
Obviously the choice depends on the size of your project, if it is relatively small the risk to lose control over your internal architecture is low.
Despite my English level I hope this could be useful to you-
Likes: Apollo14, antix