sprite

Get single sprite from sprite atlas

自作多情 提交于 2019-12-25 04:07:02
问题 I'd like to get a single sprite which GameObject has in a SpriteRenderer component. Unfortunately, this code returns the whole atlas, but I need to a part of this atlas. Texture2D thumbnail = GetComponent<SpriteRenderer>().sprite.texture; 回答1: There is no native API to get single sprite from the SpriteRenderer and no API to access individual Sprite by name. You can vote for this feature here. You can make your own API to get single sprite from Atlas located in the Resources folder like the

Google maps image marker is not placing correctly in the sprite

☆樱花仙子☆ 提交于 2019-12-25 03:46:15
问题 I'm trying to use a sprite image for google map marker but it does not display. Here is the code I'm using function setMarkers(map, markers) { var google_image = new google.maps.MarkerImage("http://www.mydomain.com/images/bodycss/pointer.png", new google.maps.Size(32, 32), new google.maps.Point(28, 32)); for (var i = 0; i < markers.length; i++) { var sites = markers[i]; var siteLatLng = new google.maps.LatLng(sites[1], sites[2]); var marker = new google.maps.Marker({ position: siteLatLng, map

rotate a sprite around an anchor point

混江龙づ霸主 提交于 2019-12-25 03:34:27
问题 I have a sprite : ombreoeuf1 = [CCSprite spriteWithFile:@"mangeurcentremieu3_03.png" ]; ombreoeuf1.position = ccp(240,160); [self addChild:ombreoeuf1]; And I would like to rotate it constantly around an anchor point. How can I do it? 回答1: You can first set anchor point by setting the property anchorPoint , for example: [ombreoeuf1 setAnchorPoint:ccp(0,0)] and then set rotation (in degrees) by setting another property rotation : [ombreoeuf1 setRotation:90] anchorPoint and rotation are both

rotate a sprite around an anchor point

≯℡__Kan透↙ 提交于 2019-12-25 03:34:17
问题 I have a sprite : ombreoeuf1 = [CCSprite spriteWithFile:@"mangeurcentremieu3_03.png" ]; ombreoeuf1.position = ccp(240,160); [self addChild:ombreoeuf1]; And I would like to rotate it constantly around an anchor point. How can I do it? 回答1: You can first set anchor point by setting the property anchorPoint , for example: [ombreoeuf1 setAnchorPoint:ccp(0,0)] and then set rotation (in degrees) by setting another property rotation : [ombreoeuf1 setRotation:90] anchorPoint and rotation are both

Rotate sprite around pivot with finger drag

[亡魂溺海] 提交于 2019-12-25 02:26:25
问题 I am rotating a clock hand around clock center, and I am using: Vector3 dir = mouseClickPos - transform.position; float angle = Mathf.Atan2(dir.y,dir.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); And it is working like a charm. But I need it not to go smooth but to skip around 15 degrees. How can I do that? 回答1: Try angle=Mathf.Round(angle/15f)*15f (sorry for the wrong math at first, need coffee) 来源: https://stackoverflow.com/questions/24673043/rotate

How to make my button change on collision

半世苍凉 提交于 2019-12-25 01:05:14
问题 Hey I am trying to make my sprite button go from green to red and backwards when my player collides with it. I have a boxcollider2d as is trigger, and a script script : https://gyazo.com/ec64a2bca5b23526c6949bf18cb50a0d I think this is some of it but I dont get anything at all when colliding with the button can anyone enlighten me on this problem would be very appreciated. Thanks in advance 回答1: It is important to distinguish the difference between Colliders and Triggers. Colliders are used

LibGDX Android Game - displaying fixed text (ie Score) over a scrolling screen

ぃ、小莉子 提交于 2019-12-24 18:09:09
问题 I am beginning to write a game in LibGDX, only just beginning. I have got a basic tile map loaded, a player sprite and can move the character around and the screen (camera) scrolls around - perfect. I have two overlayed textures in the bottom right of the screen, a left and right arrow, which are used as the joypad to control the character. I position these in relation to the players.x position, which is always fixed to the centre of the screen. Cool so far .... As below: ////////////////////

LibGDX Android Game - displaying fixed text (ie Score) over a scrolling screen

烂漫一生 提交于 2019-12-24 18:09:02
问题 I am beginning to write a game in LibGDX, only just beginning. I have got a basic tile map loaded, a player sprite and can move the character around and the screen (camera) scrolls around - perfect. I have two overlayed textures in the bottom right of the screen, a left and right arrow, which are used as the joypad to control the character. I position these in relation to the players.x position, which is always fixed to the centre of the screen. Cool so far .... As below: ////////////////////

how to use a sprite as an anchor point of another sprite?

纵然是瞬间 提交于 2019-12-24 13:26:15
问题 I want to know , if you can , join two sprites in libgdx . Let me explain, I have a spaceship that I have to turn in my game ... and is the first sprite . another sprite I would put on the tip of the spacecraft so that when it turns me I through the second sprite I can always know the coordinates and so derive a vector in order to advance my ship . I'm new to libgdx and if anyone had any idea would be grateful. Thank You. EDIT : I would follow that always render the position of the other

Force a sprite object to always be in front of skydome object in THREE.js

偶尔善良 提交于 2019-12-24 12:33:44
问题 I currently have a custom shader draw a gradient on a skydome and would like to have a sun/moon in front of the skydome (from users perspective). The easiest way to do this is to have sprites for the sun and moon but the problem that arises is that the sprites get lodged within the skydome (sprite is partway in front and partway in back of the skydome). I have attempted to solve this with polygonoffset, but that doesn't seem to work on sprite objects. So my question is, how can I setup a sun