Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
TNT Animator Studio issue. — Gideros Forum

TNT Animator Studio issue.

joelghilljoelghill Member
edited November 2012 in General questions
Hello,

I've got a strange issue with the animator studio that I can't seem to fix on my own. I'm trying to add a series of animations to my Player class, however none of them seem to be visible. This is odd, as they were working fine earlier and I can't remember what changes I've made to my code or working space that could cause this.

I've narrowed it down to the animations. The player is in the correct layer and responds to touch and accelerometer event's. For example, if I replace all of the animator code with displaying an image, the image is displayed and interacts with the environment just fine.

I'll try and add the relevant code here. Did I miss something really simple when working with animator studio?
Player = Core.class(Sprite)
 
function Player:init()
 
	--[[self.image = Bitmap.new(Texture.new("Assets/grfx/mario_ani.png"))
	self:addChild(self.image)]]
 
 
	self.gravity = 1 --was 1
	self.flighttMax = 200
	self.flight = self.flightMax
 
	self.startX = 150
	self:setX(self.startX)
	self.hold = false
 
	self.xAccel = 0
	self.yAccel = 0
 
	self.xVel = 0
	self.yVel = 0
 
	self.newY = 0
	self.newX = 0
 
	self.mass =-100
 
	self.maxAccel = 30
	self.maxVel = 30
 
	self.onGround = false
	self.onWallLeft = false
	self.onWallRight = false
	self.onRoof = false
 
	filter = 0.1
 
	fx = 0
	fy = 0
	fz = 0
 
	self.Oy, self.Ox, self.Oz = accelerometer:getAcceleration() -- get oridentation at startup
 
	self:addEventListener(Event.MOUSE_DOWN, self.mouseDown, self)
	self:addEventListener("enterFrame", self.onEnterFrame, self)
 
-- Load textures and create texture package
	self.animationTexturePack = TexturePack.new("Assets/grfx/mario_ani.txt", "Assets/grfx/mario_ani.png")
	---------------------------------------------------------------------
---------------------------------------------------------------------
 
-- Load animatoions and set to player.
-- init texture animation loader and read animations... 
	self.aniLoader = CTNTAnimatorLoader.new()
 
-- read nimation infos 
	self.aniLoader:loadAnimations("Assets/grfx/mario_ani.tan", self.animationTexturePack, false)
 
-- create animation
	self.lastDirection = 1
	self.anim = CTNTAnimator.new(self.aniLoader)
	self.anim:setAnimation("REST_RIGHT")
	self.anim:playAnimation()
    self.anim:addChildAnimation(self)
	self.anim:setVisible()
-- add animation as child of player
	self:addChild(self.anim)
 
 
---------------------------------------------------------------------
end
 
function Player:onEnterFrame(event)
	if not pauseGame then
	-- get accelerometer values
	local y, x, z = accelerometer:getAcceleration()
	x = x - self.Ox
	y = y - self.Oy
	z = z - self.Oz
 
	-- do the low-pass filtering
	fx = x * filter + fx * (1 - filter)
	fy = y * filter + fy * (1 - filter)
	fz = z * filter + fz * (1 - filter)
 
 
	self:updateXAccel()
	self:updateVelocity(event.deltaTime)
	self:updateAnimation()
	self:updatePosition()
 
	end
end
 
function Player:updateAnimation()
 
	if self.xVel < 0 then --moving left
		if self.onGround == true then
			self.anim:setAnimation("RUN_LEFT")
			self.anim:setSpeed(math.abs(self.xVel))
			self.lastDirection = 3
 
		elseif self.onGround == false then
			self.anim:setAnimation("JUMP_LEFT")
			self.anim:setSpeed(math.sqrt(self.xVel*self.xVel + self.yAccel*self.yAccel))
			end
	elseif self.xVel > 0 then
		if self.onGround == true then
			self.anim:setAnimation("RUN_RIGHT")
			self.anim:setSpeed(math.abs(self.xVel))
			self.lastDirection = 4
 
		elseif self.onGround == false then
			self.anim:setAnimation("JUMP_RIGHT")
			self.anim:setSpeed(math.sqrt(self.xVel*self.xVel + self.yAccel*self.yAccel))
			end
 
 
	else
		-- set to idle animations
		if self.lastDirection == 3 and self.onGround == true then
			self.anim:setAnimation("REST_LEFT")
		else if self.lastDirection == 3 and self.onGround == false then
			self.anim:setAnimation("JUMP_LEFT")
		elseif self.lastDirection == 4 and self.onGround == true then
			self.anim:setAnimation("REST_RIGHT")
		elseif self.lastDirection == 4 and self.onGround == false then
			self.anim:setAnimation("JUMP_RIGHT")
 
		end
	end
 
	end	
 
end
Tagged:

Comments

  • GregBUGGregBUG Guru
    edited November 2012
    i try....
    it's seems obvious but...
    forgot to add "player object" to stage ?
    stage:addChild(Player)
    :D
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Haha. Nope, I checked that :P The player is on the stage. It's not hidden behind anything either. The camera I have responds to my player class, and touch events for the player still work.
  • ok.
    i think is
    self.anim:setVisible()
    need to change to:
    self.anim:setVisible(true)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Nope, that didn't seem to do the trick either. I should mention that I'm using the latest versions of everything, however this was an issue with TNT Animator 1.0.

    The issue came out of nowhere, it's very strange. It was working just fine a while ago. I have no idea what I did!
  • mmm...

    can you send me a simple "working code" with the same issue?
    maybe a bug on my side...

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Away from the computer now, but I'll put something together when I get home.
  • Alright, so I've attached my project as it is now. I think all of the assets are included in the zip. If I've missed something, let me know and I'll put together a different working code.

    player.lua is where the animation is handled, along with accelerometer and tap events.

    The project should boot into a level with a character on screen. When working properly, you should be able to run around a very simple 2d map.

    I apologize in advance, my code may not be commented all that well and it's kind of a mess.

    On another note, feel free you use any code I've got here for other projects! That goes for anyone reading this :)
    zip
    zip
    Leyenda Playground 2.zip
    619K
  • GregBUGGregBUG Guru
    Accepted Answer
    ok. i think now is solved.

    1. download and update your TNT Animator Studio (libs that you are using are outdated and OLD)

    2. Some Code change in Player class:

    on player:init()
    --   self.anim:addChildAnimation(self) -- this is deprecated from v1.04
    	self.anim:addToParent(self) -- use this.
    tested on my Win8 dev machine (desktop Player) and on my iPod test device.
    and is working fine. (have a nice mario that jump and walk around!)


    let me know if it solve.

    Ciao!
    :D
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Ah! I had downloaded the new studio, but I must have copied over the wrong library into Gideros! D'oh!

    Thanks so much!
Sign In or Register to comment.