It looks like you're new here. If you want to get involved, click one of these buttons!
function Page0:init( pageNo, parent) -- [[ _QUESTION_1_: is ".no" a variable of the function Page0:init? ".background" is also a variable of the same function? ]]-- self.no = pageNo self.background = Bitmap.new(TextureRegion.new(Texture.new("assets/bg.png", true))) self.button= Bitmap.new(TextureRegion.new(Texture.new("assets/button.png", true))) -- just read texture pack dog local dogTexturePack = TexturePack.new("assets/dog.txt", "assets/dog.png") local dogLoader = CTNTAnimatorLoader.new() dogLoader:loadAnimations("assets/dog.tan", dogTexturePack, true) --[[ _QUESTION_2_ According to the example provided with TNTanimator I need to declare the dog class as Sprite: does using CORE.Class(Sprite) instead of GIDEROS.Class(Sprite) (as seen in other examples) make any difference? ]] dog = Core.class(Sprite) function dog:init() self.dog= CTNTAnimator.new(dogLoader) self.dog:setAnimation("DOG_STOP") -- [[ _QUESTION_3_ : What does the following line exactly do? If I remove it, I remove the dog from stage. But I expected that it was self:addChild(object) "giving birth" to things. (see below, QUESTION5 ) ]]-- self.dog:addToParent(self) self.dog:playAnimation() -- _QUESTION_4_: why SELF: and not SELF.DOG? (self.dog places dog to 0,0 on screen) self:setPosition((Swidth /2),(Sheight -150)) end self:addChild(self.background) self:addChild(self.button) --[[ _QUESTION_5_ (this is the line I was referring to in question3) . Is there another way/method to "call my dog?" ]]-- self:addChild(dog.new()) --this is coming from page4 and needed for touch event self:addEventListener(Event.ADDED_TO_STAGE, self.onAddedToStage, self) self:addEventListener(Event.REMOVED_FROM_STAGE, self.onRemovedFromStage, self) end --this is also coming from Page4: I just changed the names accordingly. function Page0:onMouseDown(event) --[[ _QUESTION_6_ : The following line of code on touch gives ERROR "attempt to index field 'dog' (a nil value)" ]]-- if (self.dog:hitTestPoint(event.x, event.y) == true) then print("TOUCH") --[[ If I change it this way: if (dog:hitTestPoint(event.x, event.y) == true) then print("TOUCH") (dog instead of self.dog) I get this other error "index '__userdata' cannot be found" What am I doing wrong? What is __userdata? I also tried changing the hittestPoint area to a Bitmap (button in my code), which is working: but then I have another error trying to GTWeen the dog. (gtween.lua:163: attempt to index field 'target' (a nil value)) Gtween was working when the dog was an AnimatedSprite() I suppose I can't refer to TNTanimatedObjects as I would refer to AnimatedSprites or Bitmaps in GTween lib. How do I address those? ]]-- end end function Page0:onAddedToStage() -- we need mouse functions to interact with the toy self:addEventListener(Event.MOUSE_DOWN, self.onMouseDown, self) end function Page0:onRemovedFromStage() end