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.


Messages - DemiGoth

Pages: [1] 2 3
1
Support / Re: TextMesh size in pixels
« on: May 27, 2015, 10:47:37 am »
Yup thats it. Its not 100% accurate as the name suggests but its very very close :)
Close enough for me. Just add an extra 10px and it should be fine (I hope  ;) )

2
Support / Re: TextMesh size in pixels
« on: May 24, 2015, 08:01:50 am »
Nvm, got it figured out -> GetEstimatedMeshBoundsForString(string str). And from the looks of it, it's quite accurate as well. Now it's time to get building the ticker I want to make ;-)

3
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...

4
Support / Re: How to change the alpha of a "Sprite from texture".
« on: February 26, 2014, 07:38:14 am »
Thank you...

I've figured it out - After learning how to make it was pretty easy actually.

Care to share your solution? I'm in need of some alpha transforming as well ;)

[EDIT]

Found it myself as well -> myObject.color= new Color32(0,0,0,128); // Black & half-transparent Using it to gray-out non essential menu objects....

5
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

6
It is already two sprites of course, the knife is its own sprite while the rope is a tiled sprite

What you've said is exactly the same as what I said except just reversed. Even if I keep the anchor of the rope on the knife I still need to extend the dimension.x value but in relation to the character instead of the knife.

Uhm, now I look at it again, you're right (was pretty tired earlier today  :-\ ).

Okay, algorithm then (not programming, just working it out in words leaving the programming to you :D )

Calculate distance between char.x and knife.x. In the middle drop the rope sprite and set rope.x length to knife.x-char.x  (there's a special distance function for it in Vector iirc - makes it easier when you can throw the knife over the y-axis as well).

7
I think the easiest way is to make 2 sprites: one for the knife and one for the rope. 

Then let the rope sprite increase in the x-pos the further the knife gets from the character. Mean while start tiling the rope sprite along the x-pos.

8
Support / Re: Instantiate sprite & SetSprite()
« on: February 19, 2014, 08:19:34 am »
Okay, NVM... Silly me (once again). I should make the myObject public and drop the original sprite there. Instantiating the new ones will automatically get the myObject from the instantiated sprite  :-[

9
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?

10
Support / Re: Chance camera background color
« on: February 16, 2014, 03:03:17 pm »
Just shoot me... Tried this before and it was not working and now it is ...or I must have made a typo somewhere :-\  ANyway, it's working now and BIG THANKS for the help AND patience  :-*

11
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  :-[

12
Support / Re: Chance camera background color
« on: February 16, 2014, 01:02:46 pm »
Okay, that's clear. But how do I change the background color of the tk2dCamera that I'm using? In your tutorials you state clearly that you need to remove the default (3D) camera and use the tk2dCamera instead. And with that one not having a backgroundColor property I'm wondering how to set it.

I did use camera.BackgroundColor=Color.blue, and the camera (when I added it) did change to blue, but as said above, it's not showing up on the tk2dCamera.

13
Support / Re: Chance camera background color
« on: February 16, 2014, 07:20:50 am »
camera.backgroundColor = Color.blue; Works, but only on the normal camera. The tk2dCamera doesn't allow this to be used. Did you remove the tk2dCamera on your latest release?

14
Support / Re: Chance camera background color
« on: February 15, 2014, 05:25:57 pm »
Tried that one already and I get "Assets/Scripts/MainGame.cs(168,40): error CS1955: The member `UnityEngine.Camera.backgroundColor' cannot be used as method or delegate" when I use camera.backgroundColor(Color.blue).

When I use myCamera.backgroundColor(Color.blue) (derived from tk2dCamera) I get "Assets/Scripts/MainGame.cs(168,42): error CS1061: Type `tk2dCamera' does not contain a definition for `backgroundColor' and no extension method `backgroundColor' of type `tk2dCamera' could be found (are you missing a using directive or an assembly reference?)".

15
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?

Pages: [1] 2 3