Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - DemiGoth

Pages: [1]
1
Support / TextMesh size in pixels
« on: May 23, 2015, 03:26:34 pm »
I'm looking for a way to calculate the size in pixels of a TextMesh. I know that fonts like Courier have a fixed width, but others like Times New Roman don't. It's for those fonts that I need to know the length in pixels of the text written...

2
Support / Google's Admob plugin & 2D toolkit
« on: February 20, 2014, 05:44:54 am »
Simple question if they are compatible with each other. I have tried to get it working for Android, but the Admob plugin does get called (I see debug information when I play in the editor), but I never see an ad on my Android phone

3
Support / Instantiate sprite & SetSprite()
« on: February 19, 2014, 08:14:10 am »
I have a problem with the game menu I'm creating.

To create a menu, I instantiate the menu sprites to the screen from the main game loop. Attached to each sprite I have the following code.

Code: [Select]
using UnityEngine;
using System.Collections;

public class OptionMenu : MonoBehaviour
{
public tk2dCamera myCamera;
static private tk2dSprite myObject;
byte MyMenuOption;

// Use this for initialization
void Start ()
{
Vector3 StartPos;

myObject=GetComponent<tk2dSprite>();
StartPos=myObject.transform.position;
if(StartPos.x==myCamera.nativeResolutionWidth/2 && StartPos.y==myCamera.nativeResolutionHeight-50)
{
// TetraGems logo
myObject.SetSprite(2);
MyMenuOption=1;
}
else if(StartPos.x==myCamera.nativeResolutionWidth/2 && StartPos.y==100)
{
// Start button
myObject.SetSprite(3);
MyMenuOption=2;
}
else if(StartPos.x==myCamera.nativeResolutionWidth-75 && StartPos.y==0)
{
// Exit button
myObject.SetSprite(6);
MyMenuOption=3;
}
else if(StartPos.x==125 && StartPos.y==myCamera.nativeResolutionHeight/2+100)
{
// Next Blocks button
myObject.SetSprite(8);
myObject.transform.Rotate(0f,0f,350);
MyMenuOption=4;
}
else if(StartPos.x==125 && StartPos.y==myCamera.nativeResolutionHeight/2-50)
{
// Next Gems button
myObject.SetSprite(10);
myObject.transform.Rotate(0f,0f,10);
MyMenuOption=5;
}
else if(StartPos.x==myCamera.nativeResolutionWidth-125 && StartPos.y==myCamera.nativeResolutionHeight/2+100)
{
// Music button
myObject.SetSprite(12);
myObject.transform.Rotate(0f,0f,350);
MyMenuOption=6;
}
else if(StartPos.x==myCamera.nativeResolutionWidth-125 && StartPos.y==myCamera.nativeResolutionHeight/2-50)
{
// Sound Effects button
myObject.SetSprite(14);
myObject.transform.Rotate(0f,0f,10);
MyMenuOption=7;
}
else if(StartPos.x==75 && StartPos.y==0)
{
// Credits button
myObject.SetSprite(15);
MyMenuOption=8;
}

if(MyMenuOption>2)
{
myObject.scale=new Vector3(1.5f,1.5f,1.5f);
}
else if (MyMenuOption==2)
{
myObject.scale=new Vector3(2f,2f,2f);
}
}

// Update is called once per frame
void Update ()
{
if(MyMenuOption>0 && MainGame.GameState>=20)
{
// Game no longer in menu mode - destroy object
DestroyImmediate(gameObject);
}
}

void OnMouseDown()
{
switch(MyMenuOption)
{
case 2: // Play
MainGame.GameState=20;
break;
case 3: // Exit
Application.Quit();
break;
case 4: // Next Blocks
myObject.SetSprite(9);
break;
case 5: // Next Gems
myObject.SetSprite(11);
break;
case 6: // Music
myObject.SetSprite(13);
break;
case 7: // Sound Effects
myObject.SetSprite(15);
break;
case 8:
break;
}
}
}

Each menu option ends up on their appropriate location. But when I click for MyMenuOption 4 trough 7, the sprite for MyMenuOption 8 (not yet coded :p) changes.

How can I let each sprite change their own instead of the last one I instantiated?

4
Support / Shades on fonts
« on: February 16, 2014, 01:32:24 pm »
I'm trying to make my own fonts and I have downloaded BMFont for that. After having had a couple of issues to get it to export in the right format, I'm getting there. But the one thing I can't get done is that extra shade you have on the (demo) GradientFont. How to add a shade to my own fonts?

[EDIT]

nvm... found it. BMFont has an option for 'Outline thickness' at the bottom of the Font Settings  :-[

5
Support / Chance camera background color
« on: February 13, 2014, 08:08:46 am »
I'm trying to figure out how to change the camera background color. As far as I can see, there's only an to GET the background settings and not SET it. Is this correct? If not, how can I SET the camera background color?

6
Support / New line in textmesh
« on: February 11, 2014, 03:09:03 pm »
I'm wondering how to put a new line in a textmesh from code. I know how I can put it on screen from the Unity Editor, but I really need to use a next line in my code that I use in some cases.

7
Support / 'Reading' actual display size
« on: January 27, 2014, 06:31:28 am »
Is there a way to read the actual display size? With my game getting ready for testing and porting to Android, I do need to move stuff (UI elements) along the display and knowing the actual size of the display would help greatly with it.

8
Support / Sprite Collection disappearing upon game start
« on: November 20, 2013, 07:13:40 am »
I've made a couple of sprites to use as overlay (game pause & game over to start with) and have declared it like this in my code:

Code: [Select]
public class MainGame : MonoBehaviour
{
public tk2dSprite myGameOverlay;

void Start ()
{
myGameOverlay = GetComponent<tk2dSprite>();
}

I have also dragged & dropped the Overlay sprite collection into my code and it's there just fine. But the moment I run my game it disappears and the field for sprite collection is empty again, only to reappear the moment I end my game. I can drag & drop it there while playing and it works normally.

Any idea how this comes and how to get it working as it should?

9
Support / Instantiate into ANCHOR camera?
« on: November 13, 2013, 06:48:20 pm »
For my upcoming (heavily modified) Tetris game I need to break down the dropping blocks into bits. I figured to make a prefab of the colored (1x1) blocks, drop one on the screen (BEHIND the camera reach) and then use Instantiate to clone it. For the easy of testing I'm using the press of N to create it on a hard-coded spot.
Code: [Select]
using UnityEngine;
using System.Collections;

public class TetrisBits : MonoBehaviour
{
public Transform myObject;

// Use this for initialization
void Start ()
{
}

// Update is called once per frame
void Update ()
{
if (Input.GetKey(KeyCode.N) && Input.GetKeyDown(KeyCode.N))
{
Instantiate(myObject, new Vector3(176,261,1),myObject.rotation);
}
}
}
Well, code works, but it's not created on (176,261,1) in the anchor where the prefab sprite resides, but instead it's on those coordinates in the MAIN camera (and thus waaay off where I want it :(). Now I'm wondering how I can tell the object to appear under the anchor it's parent is instead of the clone popping up on the main window. Also worth to note that myObject.rotation is not working as 'anchor' as the tutorial on the Unity site tells me.

10
Support / Unity 4.3 hanging upon close
« on: November 13, 2013, 09:48:35 am »
Now that I've upgraded to Unity 4.3 and 2D toolkit 2.3, I get more hangups in Unity upon shutdown than before. Since I'm only using 2D toolkit as additional asset, and the 2.2.3 version had similar hangup problems, I thought to drop the problem here as well...

The hangups mostly occur when I've tested my program in the Unity editor (using PLAY button) a couple of times and want to exit Unity. When doing so, nothing happens, other than Unity hanging itself up (not responding in taskmanager) and I have force-close it.

11
Support / Spine & 2D toolkit 2.3
« on: November 13, 2013, 06:36:39 am »
I'm wondering if Spine is still working with 2D toolkit 2.3 (and Unity 4.3), or does Spine needs to update it's runtimes as well?

12
Support / tk2dSprite.SetSprite() bug?
« on: November 11, 2013, 07:26:56 am »
After my previous support request here, I think I might have found a bug with the tk2dSprite.SetSprite() method.

As said, I'm making a Tetris game, and for this I've created a sprite collection holding the 7 blocks that need to drop. For all of these blocks I've set their own polygon collider boundaries over the edges of the object. So far so good....
But when I change the Tetris block to play with using the tk2dSprite.SetSprite() method, the polygon collider of the 'default' block that I'm using on the camera sticks to the Tetris block. i.e. When I set the O (2x2 blocks) as default and I get an I (1x4 blocks), the collider is still set to the O (2x2 blocks).

I'm not sure if I miss something when changing sprite and have to change collider as well, but IMO when changing sprite the collider should change with it.

13
Support / Colliding halfway through
« on: November 11, 2013, 06:14:41 am »
I'm making my own variation on the old Tetris game and am now at the part where I can start on collision for the objects (falling block, frame and the blocks on the bottom). To do this I'm experimenting with the OnTriggerEnter() and the function only has one Debug.Log instruction to tell me it actually IS colliding. I do get the Debug.Log message in the console, but... The message appears when the Tetris block is already halfway through the bottom of the frame :(

How do I get actual collision of the Tetris blocks and the frame the moment they touch? For both I've made polygon collides around the edges of their textures, because this is where the collision has to occur.

Also worth to add is that the moment my game starts (and the Tetris object is floating top center and not touching anything) the collider is triggered...

Pages: [1]