is there a way to blend two sprites into one?

Kirika

Villager
Member
Joined
Aug 12, 2014
Messages
23
Reaction score
1
First Language
na
Primarily Uses
N/A
for example i got

var spriteA = new Sprite();

var spriteB = new Sprite();

Is there a way to blend them together(possibly with different blend options) and receive spriteC as result?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Well, you could:


- blt() the bitmaps of both sprites and a 3rd bitmap and create a Sprite from it.


- Use PIXI.RenderTexture, render both sprites on it, create a new Bitmap from its Base64 representation and create a Sprite from it (more complicated, but might be faster).


Also, you could maybe create a PIXI filter from one sprite and apply it to the other one, but i don't know if that works across both Canvas and WebGL.
 
Last edited by a moderator:

Kirika

Villager
Member
Joined
Aug 12, 2014
Messages
23
Reaction score
1
First Language
na
Primarily Uses
N/A
ok - then another question

context.save();
context.fillStyle = color;
context.fillRect(x1, y1, x2, y2);
context.restore();

something like that will make rectangle and fill it with color (u can play with gradients and so on here too)
but how to fill it with image in rmmv - i seen some examples how to make it in html5 using context.drawImage(img,x,y,w,h);
but i cant figure out how to make rmmv to load my image in to img here.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
You usually don't directly with the canvas, but with Bitmap and Sprite objects (or the underlying pixi objects, but most of the time you don't need this). If you want to display a picture, you would do it like this:

var sprite = new Sprite(Bitmap.load('img/enemies/Angel.png'));scene.addChild(sprite);Where "scene" is the current scene (usually "this", because you are adding images inside a scene's "create" function).The first part create a Bitmap object from the given image and creates a sprite from it. The second part adds the sprite to the scene, because it wouldn't be visible, otherwise.
 

Kirika

Villager
Member
Joined
Aug 12, 2014
Messages
23
Reaction score
1
First Language
na
Primarily Uses
N/A
yap - but i need to compose it from different images before i addchild it
or more accurate - i got it already composed from moving primitives (like rectangle scripts posted above and gradient patterns) - now i want to blend image directly in to it, and affect of blanding it as addchild or darken whole image to much or partially override it depends from blending option, so i thought to merge background with image first and then render it with other objects.
allthough now i got an idea to cut background from pixi rendered sprite and try to blend it with my image as sprite too - thanks for hint.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top