Tag Info

New answers tagged

1

You don't want to actually resize the sprite. What you want to do is resize the texture this sprite is being rendered on. Once you get the texture you can call Texture2D.Resize(Screen.width * 0.2f, Screen.width * 0.2f) If you're not sure which texture you are using, you can call Sprite.texture to get the texture used. If you wanted to, you could even do ...


0

As Maksim said about canvas pixels. You can draw your sprites in unusual way. I can share what I have been working on last week. function drawImageBlended(src, sx, sy, dest, dx, dy, w, h, blendMode) { var srcCont = src.getContext("2d"); var srcData = srcCont.getImageData(sx,sy,w,h); var sPixels = srcData.data; var destCont = ...


0

The answer I gave in the other question doesn't quite do exactly what you want, but the following example might help. You still need to re-proportion both the heights to do what you want, but you also need to move the input data region down to compensate for the smaller window: spriteBatch.draw( sprite.getTexture(), x, y, width / 2, ...


0

It's quite possible to partially draw a sprite using the SpriteBatch.draw(Texture,...) rather than the SpriteBatch.draw(TextureRegion,...). As long as you only intend to draw a rectangular sub-section of that sprite. Note, Sprite is a TextureRegion. If you have a Sprite that you are already drawing, you can get the Texture itself from the Sprite using the ...


1

Please consider this first-party library; it is from MS, so if it is not-third-party enough for you, it will make your life considerably easier. It provides an interface to DX11 that is very similar to XNA. Specifically, SpriteBatch, SpriteFont, etc.. Rastertek and Reimer's are generally helpful. For Rastertek, I linked directly to their DX11 2D tutorial, ...


2

Instead of using LookAt, you can have the shader force the object to be rendered facing the camera. Thus, no script needs to be added to the tree, and the extra work the shader does is very little. Here's an example: Billboard Shader Also, since they don't actually move or rotate (as far as the CPU is concerned) and share the same material, you can turn on ...


0

If you are working solely with Sprites I do not believe there is a good way of drawing part of a Sprite. If you want to keep working only with Sprites I would recommend splitting the original Texture beforehand and creating a separate Sprite for each piece. However, if you could work with Textures (i.e. you do not need to rotate the partial Sprite) then you ...


0

Yeah that would work. Commonly when a game wants to have the animation and location synchronized like this, they will have a fixed time delta that is passed to both their simulation (what moves the object) as well as the animation system. Your idea would also work though (:


1

I don't think it is a good idea to mix logic and art; or more precisely, base your logic on your art. In simpler terms, don't do what you're doing. Separate logic from art. The idea behind this is that the person who draws the sprites should be able to do any kind of drawings and change them at will, without having to worry that artistic changes will have ...


0

Well, I found how to fix. You have to recreate the project, and then before put all the sprites together, you have to unmark Generate MipMaps and change filter mode to point. Do this without creating a new project(inside of the project already done) didn't worked. Then after replacing all the slices, you put the material with Sprites/Diffuse.


0

I haven't tested the code but I can foresee one possible problem. Once you change the sprite to spr_player_jump you don't change it to spr_player_idle or spr_player_run until there is a place meeting at x,y+1, obj_wall. Normally this might be okay but if your origin is at the center and not the bottom of the sprite's feet it won't trigger. The x,y location ...


0

You need to do this as a hierarchy. Have a main Object that you move and run all your code on, and then add the sprite as a child object and rotate the sprite object only so it aligns the way you want it to.


0

I had the same problem. I've made some experiments with different types of sprites (single and maps). I've tried to add transparent border to my sprite map in Photoshop, but it didn't work. Then I separated the sprites from my sprite map. It worked for me. It seems that the problem is with sprite maps.


1

I believe that in a lot of cases it's not worth investing huge amounts of time into optimizing assets to shave off a few MB of your final game. Sure, if you need to stay below a certain size limit (eg. 100MB for Apples policy for apps to transfer over cellular-networks), then it's reasonable. A general optimization you can do is making use of some PNG ...


0

I think you could save a lot of space if you drew those circles either as vectors (if Unity doesn't have vector graphics you can probably find libraries you can use with Unity that do) or if you had one circle and made coloured and resized versions in memory when your application runs. If you pack your colourful food together on one 512x512 sheet and then ...


0

if egg.cs is attached to the egg, then writing: transform.GetComponent<SpriteRenderer> ().sprite = changedContainer; will change the egg component, so maybe use target.gameObject.transform.GetComponent<SpriteRenderer> ().sprite = changedContainer;


1

Whichever option is easier for you to work with, you are unlikely to push the hardware limits with a 2d game so you should get a good framerate with either approach. Using a Group and place components in it means you can detect mouse clicks on each element the same as any other JavaFX control. Drawing into a Canvas is more similar to how a fully fledged ...



Top 50 recent answers are included