article thumbnail

2D gaming performance

Cocos

As soon as the script detects that a black screen will appear soon, the script generates ground. Then I generate nodes (sprites) from this array and add them to the playing field. Then I generate nodes (sprites) from this array and add them to the playing field. I encountered a performance problem.

Sprite 52
article thumbnail

How to change the offset of a Tiled Sprite

Cocos

Hi, i want to apply a sprite as a tiled background and apply to it an animation like a movement. I don’t want to make a script that calculate position and if at certain value must to set the start position. I want to give this effect changing the “offset” of the texture/sprite of it. This Node has a sprite set as Tiled

Tile 40
Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Trending Sources

article thumbnail

Tag to prefab dynamically and intersect in script

Cocos

I want to do this in the creator-type script. count++; demo = Sprite::create(“d1”); demo->setPosition(Vec2(362.399170,831.098450)); demo->setTag(count); this->addChild(demo); if ( this ->getChildByTag(i)->getBoundingBox().containsPoint(location)) This is the Cocos2dx code snippet. Kindly help.

article thumbnail

Noob question about scripting animation

Cocos

Currently, my client engineer has 5 cards being dealt and each card sprite pulls from a random card image on an atlas. I would like to put the image of the card’s back as the default sprite frame. I know I can change the sprite frame image in the timeline, but it needs to pull from an array. I’ve already accomplished that.

article thumbnail

Question about PolygonCollider2D

Cocos

In the editor, when you add a PolygonCollider2D to a sprite with a transparent area, the polygon is automatically created. How can I get automatic polygon creation when creating a sprite dynamically in the script code? I will be grateful for your help!

Polygon 40
article thumbnail

assetManager.parser.parse() doesn't work for Uint8Array in native

Cocos

x-release/demo/Creator3.7.3_PartialScreenshot/assets/script/Screenshot2D.ts This way, you can create an imageAsset using Unit8Array data. github.com cocos/cocos-awesome-tech-solutions/blob/3.7.x-release/demo/Creator3.7.3_PartialScreenshot/assets/script/Screenshot2D.ts

Sprite 52
article thumbnail

How to create a node (shpere,) and set the color with typescript

Cocos

Manual - Create and Destroy Nodes You can change the color by using the getComponent(Sprite) method: Cocos Creator 3.8 Manual - Access Nodes and Components I have a crash course showing some basics on creating scripts and manipulating them in typescript: [link] , I just never showed how to dynamically create nodes yet.

Sprite 40