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 - Eldh

Pages: [1]
1
Support / Re: Changing polygon collider when changing spriteID
« on: September 17, 2012, 01:13:29 pm »
it's working, thx !

2
Support / Re: Changing polygon collider when changing spriteID
« on: September 07, 2012, 07:58:35 pm »
Mhh i tried to use tk2dSprite.AddComponent(...) on an empty gameobject like you said but it does not create a collider at all...
I instantiate my prefab which contain several sprites, then i add the tk2dsprite component to the gameObject (in my prefab) cause only this need to change randomly, but i'm relatively a beginner so maybe i do something wrong ? all this happens on Start.

3
Support / Changing polygon collider when changing spriteID
« on: September 07, 2012, 11:40:03 am »
Hi,
So i instantiate a prefab, in this when i change the spriteID, randomly in my case, the polygon collider won't update. It stay the same since the instantiate.
Is there a way to update the collider when i change the sprite ?


4
Support / Re: animatedSprite and color changing
« on: August 11, 2012, 02:12:01 pm »
oh... sry for that, it was so obvious i didn't think about it. Thx.

5
Support / animatedSprite and color changing
« on: August 11, 2012, 11:30:47 am »
Hi i'm relatively new to unity and programing so sry if it's a noobish question :)
I'm trying to change randomly the color of an animatedSprite wich is itself instantiate a certain number of time. So i have an array of color and pick up one randomly, but the abimatedSprite appear to be all transparent, without color in the viewport when i it play. But if i choose one color like animatedSprite.color = Color.green it's working.
Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class spawnEnemy : MonoBehaviour
{

    public tk2dAnimatedSprite enemy;
    public Color[] colorChoices;
    public GameObject road;
    public List<Transform> spawnPoint;
    private tk2dAnimatedSprite target;
    private int n = 0;
    private int p = 0;
    private Vector3 pos = new Vector3();
 

 
    void Start()
    {

            p = Random.Range(0, colorChoices.Length);
            n = Random.Range(0, spawnPoint.Count);
            target = (tk2dAnimatedSprite)Instantiate(enemy, spawnPoint[n].transform.position, enemy.transform.rotation);
            target.color = colorChoices[p];
            target.transform.parent = road.transform;
            pos = road.transform.position;
}}
       

Pages: [1]