Hello Guest

Author Topic: tk2d camera, empty screen  (Read 8050 times)

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
tk2d camera, empty screen
« on: May 11, 2012, 12:29:02 am »
Greetings

I have a problem: while using tk2d camera, i see only background. I found http://unikronsoftware.com/2dtoolkit/forum/index.php?topic=58.0 this topic and decided to start from the clear level.

Quote
tk2dCamera mini-tutorial.

1. Create sprite collection / font, and make sure you tick "Use tk2d Camera". You will not need to set up ortho size / height as you'd normally need to. Set up as usual, and don't forget to commit.
2. In the scene, delete the Main Camera, and "Create/tk2d/Camera"
3. Create a sprite as usual - if you set up the sprite collection as in step 1, it will automatically be pixel perfect, always. Otherwise, click "1:1" to make other sprites pixel perfect. You may need to click commit on your sprite collections again for this to work properly. You will see an error in the log if this is the case.

tk2dCamera Anchor mini-tutorial.

1. Click on the camera created above, and "Create Anchor". You will have an anchor object as a child to this camera.
2. Select this anchor object, and set it up as you like - offset is the offset from the anchor. For instance if your anchor wants to be 5 pixels in from the bottom right, simply select "BottomRight" as anchor, and set offset to -5, 5 (5 pixels in horizontally, 5 pixels up).
3. Create sprites as children to this object (simply select the object, and "Create/tk2d/Sprite" will automatically parent them and these objects will now automatically be anchored.

So, i created blank level, ran through all needed collections (actually, at this moment i need only 1 collection with 45 sprites) and set there "tk2d camera", then commited. atlas0.png weights 2.5 Mb, is that okay?

Then i added camera, added anchor, parented animated sprite to anchor... and see just blank screen.

PS: also, not object is not visible by editor camera (before, it was visible).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2d camera, empty screen
« Reply #1 on: May 11, 2012, 03:18:12 am »
Hi,

The atlas0 size depends on the size of atlas texture. If its 2.5MB or so, I'm guessing its about 1024x512 uncompressed? This is the amount of memory it will occupy (it does get compressed somewhat when on disk so this number isn't as relevant there). You can improve in memory size by changing the compression mode - the dithered 16-bit modes will 1/2 the size, and the other compressed modes reduce it even more at the cost of image quality.

With the tk2dCamera, are you previewing the result in the Game window? The only place this is valid is in the game window, as there is a bug in the current version of Unity with the camera "preview" window and outline in the scene view. I have reported this bug to Unity and am awaiting a response.

The easiest way to troubleshoot this is if you can send me a repro case to support at unikronsoftware dot com. I'll be able to look into it for you and tell you whats wrong. I am compiling a list of FAQs about the tk2dCamera for a getting started guide.

Let me know.
unikron

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: tk2d camera, empty screen
« Reply #2 on: May 11, 2012, 08:10:20 am »
At first, thanks for really fast answer.

I need to animate 50 frames, each one is 50-60 Kbytes, so 2.5Mb is pretty ok. Just was wondering, if tk2d supports such size. At this point, compression and size is not that important: the most important thing is just to render amount of animated sprites.

Yep, i'm looking at Game window. Sometimes i was lucky enough to see Full Heart from your pack (i was playing with both mine and yours sprites). Also, i was able to see my animated sprite in Editor window, but never - in Game window.

Huh, situation is not that good, cause sending package to you would be really the best and fastest way to solve it. Though, i'm not sure that i can share content :(

Anyway, i'll still work on it, and report results to you in any case. Probably, i'll try to reproduce this problem using another free package with lots of animated sprites.

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: tk2d camera, empty screen
« Reply #3 on: May 11, 2012, 08:23:36 am »
PS: but anyway, i was not seeing even your template Heart sprite.

Lets try to reproduce all this stuff:
1) I open the level, erase it. It is empty now.
2) Select DemoCameraSpriteCollection, open editor, go to Settings, make sure that "Use tk2dCamera" is set.
3) Create/tk2d/Camera. Its position (0,0,-10).
4) Now Camera/Create Anchor. Leave everything as it is (UpperLeft, Offset(0,0), tk2dCamera).
5) Create/tk2d/Sprite. Sprite is parented to Anchor. Set Collection to DemoCameraSpriteCollection. Sprite is HeartEmpty.

Looking like thats it. Trying to build... Looking like it works, that's pretty good. :)

6) Change Ahcnor settings to Middle Center.
7) Create/tk2d/Animated Sprite. Select my Anim Lib.
Running...
...
...

voila, it works 0_0


My only assumption is that at yesterday night, probably, i moved camera.. but as far as i remember, i set all sprite positions to (0,0,0) and parented them to anchors. Anchors was at correct places, but, probably, i moved a camera... Though, why i started to move a camera? Probably, it was something wrong before...

Anyway, my next step is to create some more animations, so, if i'd face this problem again, or if i'd have some thoughts on it, i'll report it here.
« Last Edit: May 11, 2012, 08:31:12 am by VeTaL »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2d camera, empty screen
« Reply #4 on: May 11, 2012, 09:20:12 am »
Good to hear it works :)

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: tk2d camera, empty screen
« Reply #5 on: October 08, 2014, 09:03:24 am »
Haha, after several years i had returned to Unity and 2dtoolkit and again i faced the same issue with empty camera xD
Interesting thing is that i had found only my own post about this issue :))

The thing was that i created new sprites when camera was selected. New sprite is a child of a camera, though it has position (0,0,0), it is still behind the camera :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2d camera, empty screen
« Reply #6 on: October 08, 2014, 10:12:48 pm »
Quote
The thing was that i created new sprites when camera was selected. New sprite is a child of a camera, though it has position (0,0,0), it is still behind the camera :)

That makes sense, the near clip plane is positive by default, so anything at 0 will not be visible.