Merging 2 png and save it aka ingame creator

myew

Villager
Member
Joined
Feb 28, 2016
Messages
7
Reaction score
1
First Language
english
Primarily Uses
Hi, hope that I can find some help here.


I trying to merge 2 .png into 1 and then save it. Basically it for my character face or so call ingame creator.


I try to use below script althou there no error, but it not working.


var c = document.createElement('canvas');
var ctx = c.getContext('2d');
var image1 = new Image();
var image2 = new Image();
image1.src = "1.png"
image1.onload = function() {
ctx.drawImage(image1, 0, 0, 142, 142);
image2.src = "2.png";
image2.onload = function() {
ctx.drawImage(image2, 0, 0, 142, 142);
var img = c.toDataURL("image/png");
document.write('<img src="' + img + '" width="142" height="142"/>');}};


Will be grateful if can get this working or that another way to merge n save png


Cheers


Mike
 

InBlast

The Mad Hamster
Veteran
Joined
Nov 2, 2015
Messages
287
Reaction score
89
First Language
French
Eeeeeh... Probably I don't understand what you're trying to do, but why aren't you using an image editor (Photoshop,etc...) for this ?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
 

myew

Villager
Member
Joined
Feb 28, 2016
Messages
7
Reaction score
1
First Language
english
Primarily Uses
Eeeeeh... Probably I don't understand what you're trying to do, but why aren't you using an image editor (Photoshop,etc...) for this ?


Hi InBlast,


I trying to make a ingame generator where gamer can create their own face. I have 6 type hairstyle, mouth, beard, eye etc. It will take alot of photoshop to create all the pre made faces.


Therefore if i can get the merging working, it will save a lot of time n I can have more choice of facial feature in the game.
 

izyCoder

Villager
Member
Joined
Dec 22, 2014
Messages
26
Reaction score
11
First Language
English
Primarily Uses
I bet you want to make an in game character generator right? instead of merging the PNGs, you can rewrite the sprite class to make it so it will load 2 image. As example you have image_head.png and image_hair.png, in the sprite class you can make it load both PNGs instead of single png and draw it in canvas.


This might help:
 

myew

Villager
Member
Joined
Feb 28, 2016
Messages
7
Reaction score
1
First Language
english
Primarily Uses
I bet you want to make an in game character generator right? instead of merging the PNGs, you can rewrite the sprite class to make it so it will load 2 image. As example you have image_head.png and image_hair.png, in the sprite class you can make it load both PNGs instead of single png and draw it in canvas.


This might help:
Thanks izyCoder for the suggestion.


I try out VE plugin for past 2 days. I cant get it to work. prolly clash with some of my plugin.


I realise that I will need to equip them as weapon or armour. What I want to do is hair, beard and eye feature. So the equip menu will show my character wearing beard or eye.. kind of weird even thou i can rename them.
 

myew

Villager
Member
Joined
Feb 28, 2016
Messages
7
Reaction score
1
First Language
english
Primarily Uses
This merge image code that im trying to do: can i do it on event or i need a plugin?


Below link is a simple example of what I trying to do. (pls bear with the button graphic as i do it in a rush)


a ) The hair or others button is quote with 2 event: 1) show image 2) set variable


b ) the ok button is to 1) activate the merge img that i trying to solve and 2) change actor img after i got the merging img


http://pacumedia.com/gen/


hope that some1 can help me with this.


Cheers


Mike
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

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.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top