/** Retrieves a subtexture by name. Returns <code>null</code> if it is not found. */
        public STexture getTexture(String name)
        {
            var region = mTextureRegions.ContainsKey(name) ? mTextureRegions[name] : null;

            if (region == null)
            {
                return(null);
            }
            else
            {
                return(STexture.fromTexture(mAtlasTexture, region, mTextureFrames[name]));
            }
        }
Exemple #2
0
 public Image(STexture sTexture = null)
     : base()
 {
     if (sTexture != null)
     {
         mPivotX = mPivotY = 0.0f;
         textureManager = TextureManager.instance;
         texture = sTexture;
     }
     else
     {
         throw new ArgumentError("Texture cannot be null");
     }
 }
Exemple #3
0
        // direct adding
        /** Register a texture under a certain name. It will be available right away. */
        public void addTexture(String name, STexture texture)
        {
            log("Adding texture '" + name + "'");

            if (mTextures.ContainsKey(name))
                throw new Error("Duplicate texture name: " + name);
            else
                mTextures[name] = texture;
        }
Exemple #4
0
 /** Sets the texture of a certain frame. */
 public void setFrameTexture(int frameID, STexture texture)
 {
     if (frameID < 0 || frameID >= numFrames) throw new ArgumentError("Invalid frame id");
     mTextures[frameID] = texture;
 }
Exemple #5
0
        /** Adds a frame at a certain index, optionally with a sound and a custom duration. */
        public void addFrameAt(int frameID, STexture texture, Sound sound=null, 
		                           float duration=-1)
        {
            if (frameID < 0 || frameID > numFrames) throw new ArgumentError("Invalid frame id");
            if (duration < 0) duration = mDefaultFrameDuration;

            mTextures.Insert(frameID, texture);
            mSounds.Insert(frameID, sound);
            mDurations.Insert(frameID, duration);

            if (frameID > 0 && frameID == numFrames)
                mStartTimes[frameID] = mStartTimes[frameID-1] + mDurations[frameID-1];
            else
                updateStartTimes();
        }
Exemple #6
0
 // frame manipulation
 /** Adds an additional frame, optionally with a sound and a custom duration. If the
  *  duration is omitted, the default framerate is used (as specified in the constructor). */
 public void addFrame(STexture texture, Sound sound=null, float duration=-1)
 {
     addFrameAt(numFrames, texture, sound, duration);
 }