00:00
00:00
Newgrounds Background Image Theme

Someone gifted MetalSlayer69 supporter status!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!
Response to: AS3: Shooting not always working.. Posted June 1st, 2019 in Programming

At 6/1/19 05:24 AM, Escileus wrote: I found a solution!!, even though I don't know why it works..

I replaced:
stage.addEventListener(MouseEvent.CLICK, shootBullet, false, 0, true);
with:
stage.addEventListener(MouseEvent.MOUSE_DOWN, shootBullet);

Now it shoots every time when the mouse is clicked..


The CLICK event is fired when the mouse button is released, one single time. The MOUSE_DOWN event is fired as soon as the mouse button is pressed down—also one single time—rather than waiting for it to be released. So, you can think of the Mouse.CLICK event as being when released and the Mouse.MOUSE_DOWN event as being when pressed.


That's why you were previously getting undesirable behaviour.

Response to: on window blur, focus on window Posted April 26th, 2019 in Programming

At 4/22/19 04:38 PM, Aprime wrote: @Diki ?
Maybe you know the answer? Or can find it because I'm sure you'd be able to find the answer better than me.


Hey,


Sorry about a slow response. I've been busy.


I'm not really sure what it is you're trying to do. (That 'seconds' variable isn't declared in your snippets, so I don't know what it's for.) If all you want to do is track which iframe the mouse cursor is over, you only need the mouseenter/mouseleave events. This JS code would work:


function onEnterIFrame(iframe, event) {
  console.log("Entered Frame:", iframe.id);
}


function onExitIFrame(iframe, event) {
  console.log("Exited Frame:", iframe.id);
}


Array.prototype.forEach.call(
  document.body.querySelectorAll("iframe"),
  function(itr) {
    itr.addEventListener("mouseenter", onEnterIFrame.bind(null, itr));
    itr.addEventListener("mouseleave", onExitIFrame.bind(null, itr));
  }
);

Here's a working example of that: https://tystuff.com/if.html


If that doesn't work, I'd need a bit more information regarding what it is you're trying to do.

Response to: Bleak: Comic book idea! Posted January 26th, 2019 in Writing

At 1/26/19 09:36 PM, RogerHanna wrote: the prologue is just to give the reader a sense of mystery around the land of Bleak... an insight.


That is what a prologue should do, but you said your prologue has "LITERALLY" nothing to do with your story; nothing, nothing at all, to do with what follows. A prologue is an introduction to a story so it makes no sense to introduce something unrelated to what follows. Prologues are, generally, optional reading by their very nature but they're never unrelated.


So why is your prologue not related to the story?


If the events themselves are important to you, the author, then you should rework them so they fit the narrative that will follow. Maybe make them foreshadow future events, or establish themes and/or characters, or establish a motif, or something. What's the point of telling a small, minor story that, by our own admission, means nothing and serves no purpose?


If you want to give the reader an insight into the setting of your story, writing an introduction that has nothing to do with said story or setting isn't going to do that. Making the events of your prologue matter and echo throughout the story and, however, will. And your readers will enjoy your story all the more.


I want to stress how I am only doing precisely what you requested:


At 1/25/19 03:40 AM, RogerHanna wrote: What I ask of YOU is to ask me questions that I may not have asked myself.


I'm not sure you've asked yourself why your prologue exists, so that's what I'm asking you: Why did you write it? What is it you are working toward with that prologue? Why did those events happen and what made them happen? What purpose do those events serve?


If you can answer those questions and incorporate those answers into your story, I promise you your writing will improve.

Response to: Bleak: Comic book idea! Posted January 26th, 2019 in Writing

At 1/26/19 12:09 PM, RogerHanna wrote: the prologue has LITERALLY nothing to do with the rest of the story.


Why did you write an introduction to your story that has nothing to do with your story?

Response to: Bleak: Comic book idea! Posted January 25th, 2019 in Writing

At 1/25/19 12:26 PM, Diki wrote: You didn't state it's a story intended for children nor does it read like one.


I misread what you wrote when I responded with this sentence. I thought you meant the entirety of the story is intended for a child audience, missing you said the story is intended for adults (or YA) in real life; missing the 'in-universe' bit.


My post is too old to edit in this clarification so that's all this reply is for.

Response to: Bleak: Comic book idea! Posted January 25th, 2019 in Writing

At 1/25/19 12:01 PM, RogerHanna wrote: its a fairy tale... a bedtime story... something to scare the children of this universe. Its not fact. fighting in the forest isn't something that children think about when they are being told by their parents.


You didn't state it's a story intended for children nor does it read like one. Not wanting to describe death in detail to children is fair, but it still doesn't make sense that nobody is reacting to being surrounded by an inferno. Look at the story of Pinocchio: there's very real, raw emotion when his friend is turned into a donkey even thought it's a children's story. The scene where his grandfather is chased by the whale is even more raw and real. Children's stories need emotions, too.


Simply put: your characters aren't responding to external stimuli—that's ineffective storytelling regardless of the age of the intended audience.


At 1/25/19 12:01 PM, RogerHanna wrote: I find that you've replied to this, not to be constructive... but to be rude.


I was not rude once in my critique; I was blunt. I told you what I felt worked, what didn't, and offered explanations as to why. Your writing is never going to improve if you don't want a light being shown on its problems. I'm not attacking you or your ability to write; I'm critiquing what you wrote in this instance. I'm trying to get you to see the problems from an outside perspective so you can fix them.


You asked for feedback, I gave it. Don't take critiques personally.


To highlight that I practice what I preach: look at this response to part of a story I wrote. It is far, far more scathing than what I wrote here and below his two comments you will see my response. And using that feedback, and others, I did further revisions and improved my writing.


At 1/25/19 12:01 PM, RogerHanna wrote: I wrote this at 3am on a whim.


I can tell. My primary point was you need to proofread and revise your work by highlighting the issues a lack of proofreading and revisions can create. Put more thought and effort into your storytelling; make the scene and characters real; make the stakes feel real. You have two huge armies engaging in a massive war, dedicated to said war to the point they're risking their safety by fighting it in the middle of a massive fire. You have the makings of tension and stakes there, but you don't do anything with it.


Having said that: if you don't want a critique of your writing—or specifically don't want it from me—then I won't post future breakdowns of issues I see in anything you post. My intention is not, and never will be, to upset you.


Good luck with your story. Keep writing.

Response to: Bleak: Comic book idea! Posted January 25th, 2019 in Writing

I read your prologue and it has a few problems. First off is starting out with a cliché: Once upon a time. There's pretty much no good reason to ever write those words in narration at the start of a story; it doesn't add anything and can be safely removed.


Another issue I noticed is the armies don't behave like battling armies, or people, for that matter. Why would two armies battle each other inside a thick forest? That would make military tactics virtually impossible. Rather than being able to form a phalanx they would be scattered about. Archers and cavalry would also be useless. I can't imagine any half-competent general ordering their army to fight in a forest, let alone two of them doing it. If one was foolish enough to order their troops into the trees the other would likely just wait on the other side and shoot arrows at the ones escaping (or just set the whole thing on fire and watch them burn, but more on that in a second). It didn't seem realistic that both the entire armies would stop dead, immediately, just because a civilian was in the middle of the forest. Why does every single fighter care? Not one would prefer to keep fighting? How did the entirety of both armies so quickly become aware she was even there? Troops only a hundred feet from the front line would have no way of seeing or hearing her.


The forest being on fire didn't make sense to me. How did the forest fire start? Why are the armies not burning to death? Why are they not dying from smoke inhalation? Are there no animals scattering about, fleeing the fire? The fire doesn't seem to serve any purpose other than giving the woman something to do (i.e. extinguish it). There should also be some type of reaction from the soldiers given the danger of being in a forest fire.This is what being in a forest fire is like. I didn't get any sense of the sheer amount of danger the fire would present everyone involved.


You also have way too many ellipses, and none of them are used correctly except for here:


"But..." she continued


I'd recommend getting rid of all of them except that one and to not use them outside of dialogue.


The roaring fire, cracking of trees and screams of dying men were all drown out by the sound of her voice.
"Is THIS the land that you fight for" she whispered.


How did a whisper drown out people screaming? Also, you just a few sentences before described the forest as having fallen silent: 'the soldiers all froze... the forest fell silent'. So there's nothing for her voice to drown out.


A shadow began to blanket the clearing. Droplets of rain crashed onto the faces of soldiers.


What clearing? The setting has only been described as a thick forest. If they're no longer surrounded by trees that should be made clear.


In that instant, a hellish wind from the sound could be heard approaching quickly.


Describing events as 'could be heard/seen/felt' pulls the reader out of what's happening; it puts them at a distance. You can convey the same information without doing that:


As she spoke, a gale from the south rushed toward her and the two armies, snapping branches and felling trees.


Strong verbs like 'gale' convey imagery better than a normal verb with an adjective like 'hellish wind'. And words like 'quickly' should be removed whenever possible; adverbs are, generally, not your friend in writing. They can be useful but more often than not you want a strong verb rather than an adverb.


The primary issue with that sentence, though, is that it's telling rather than showing. If the wind is so strong and fast that it is clearly perceptible by sound alone, describe the wind doing something that could easily be heard.


Bullet-like rain falling almost level with the ground was ripping through the soldiers like paper.


Some of your writing, like this, is a bit of a trudge. This is good imagery but you're relying on two separate similes in the same sentence to convey it. The use of passive voice here is also slowing it down, taking away its significance. Consider tightening it up, something like this:


Rain shot straight down from the sky like bullets, piercing the armour and flesh of the soldiers.


This reads like a first draft in need of several revisions: there's a lot of grammatical errors and missing/misused punctuation, and a few wrong word choices (e.g. 'a hellish wind from the sound could be heard') that read like something auto-correct threw in. I can only assume that was meant to be 'south'.


The ideas behind it all, while not very original, are fine; but the execution needs work. Flesh out your characters and events. Think how real people would behave in a situation like this, and write that. Resist the temptation to get right to the exciting climax because it will lose its punch without a solid build-up.

Response to: A Haiku a Day Posted January 24th, 2019 in Writing

At 1/24/19 05:26 PM, ChronoNomad wrote: You can make haiku.


I do not agree

A haiku I cannot do

I lack such a skill.


My words you call slew

Have nothing to say or do

To read this needs will.


Wait one second now

I may have done it like you

Holy cow, haiku.

Three Short Stories—Interest Check Posted January 24th, 2019 in Writing

It's been a while since I've posted my work here and I've improved considerably—in my own opinion, at least—so I'd like to again start sharing my work. (Even if said work is incomplete.)


I'm currently working on three short stories. One is more polished than the other two (and is presently longer) but all three are still refined enough to be worth reading. I'm curious which of the three piques the most interest, if at all.


Long Pork of Long Island is the longer, more refined of the three. It's a horror story about two guys traveling to an island.


These two are very short because I'm still working on the characters and themes. I've figured out most of what the story is about but haven't gotten too far with good, proper writing yet. That said, they're still both 1100 words and 600 words, respectively.


Hunters Vortex is a bit of a horror story, though I'm planning on it mostly being suspense. I'm unsure if I should go for a western setting or modern day that just happens to be in a desert environment.


Friendly Flannan, I'll Say is going to be a detective/mystery story inspired by true events. All of the events in the story will be fiction but said true events will exist in-universe, which the characters will be aware of.


Feel free to tell me what you do like, don't like; anything. I welcome any and all feedback—it's extremely helpful.


If you did like them: Which of the three did you find most interesting/engaging? If they were all finished, complete, which would you want to read before the other two?


Thanks.

Response to: Limiting Text Input Posted January 5th, 2019 in Programming

I'm not sure if you wrote this in JavaScript or ActionScript (for Flash) but it doesn't matter because they're the same language under the hood, so I'll reference only JavaScript here but everything applies to ActionScript as well.


There isn't much you can do besides trying to convert the string to a number and then checking the result. However, you can easily ensure you that always get an actual number at the end no matter what by exploiting a property of how JavaScript's || operator works:


var userNum = Number(userInput.value) || 0;

The NaN value is considered falsey, so if any value that the user gives is no valid that assignment will be the equivalent of this:


var userNum = NaN || 0;

In JS, if there is a falsey value to the left of the || operator (i.e. the left operand) then the value to the right (i.e. the right operand) will be returned, regardless of whether that value is falsey as well. So, that will end up assigning the value 0 if Number() ever encounters a NaN value.


But, if Number() returns a valid number like this:


var userNum = Number("42") || 0;

it will return the left operand because it is truthy.

Response to: Is FlashMX current code-compatible? Posted December 20th, 2018 in Programming

At 12/20/18 05:44 AM, Syrupmasterz wrote: Is Flash MX something that current programmers know how to work with?


Probably not. Flash is dead, and furthermore Flash MX is like 15 years old so nobody uses it and, anyway, it's unlikely a developer would want to use any of the Flash suites for development (such as Flash MX or the newer Adobe Flash versions, or the most recent Adobe Animate) as those are intended for animations, not games or development.


At 12/20/18 05:44 AM, Syrupmasterz wrote: My coding knowledge is pretty close to zero, so aside from knowing how to manipulate and export finished animations into .Swfs and otherwise, I don't know how a Flash Animator would collab with a programmer.


Depends on what you're making and what skillsets the developer has, but generally you'd be making assets and exporting them into a format that can easily be read by code (unlikely to by SWF format.) If it's a 2D game a common approach is to just create spritesheets (you can also use tools such as TexturePacker to generate them for you from individual images.)


At 12/20/18 05:44 AM, Syrupmasterz wrote: I guess what I'm asking is, if I try to dip my toes into the water with a goofy game, will my .Sfws work in the typical programmer's programs?


I doubt it. SWF files would be a pain in the ass to read from for the purpose of importing assets into a game engine.


You can continue using Flash MX to create assets if you want (or look into something more modern) but I'd recommend looking into how to export your art assets into formats that can easily be read (PNGs are very common.) You can take a look at GameDev Market's 2D asset store to see how they are formatted. There's lots of free assets, so you can grab those and look at how those artists exported their assets.

Response to: Memory Leak Testing Posted December 7th, 2018 in Programming

At 12/6/18 09:29 PM, GamesArmor wrote: I know this wasn't what was asked but you should avoid this sort of stuff unless you're going to get some gainz out of it, not just for shits and giggles. Just let it go out of scope and let garbage collection handle it

C++ doesn't have a garbage collector. All memory management must be done manually or through automation that must be manually coded.

At 12/6/18 09:29 PM, GamesArmor wrote: One way is to code something that will free up the memory every time you use the new keyword or something like that.

There is no possible way to do that in C++. If you use the new keyword you must then later use the delete keyword to free up that memory. There is no other way to do it. The simplest approach is use class constructors and destructors to do that, which is how classes like std::shared_ptr work.

At 12/6/18 09:29 PM, GamesArmor wrote: But even that is not foolproof(what if an exception is thrown)?

An exception being thrown does not halt code execution, so that cannot possible cause a memory leak because of RAII.

So, it really is foolproof: Either the exception is handled and destructors are called to free up the memory, or it isn't handled and the program blows up so it doesn't matter.

Response to: All CaSinG works for URL? Posted December 5th, 2018 in Programming

At 12/5/18 03:31 PM, Aprime wrote:
At 12/4/18 06:30 PM, Diki wrote: Assuming you're not going to be using an MVC framework that would be able to do all of that for you, you can use .htaccess files with mod_speling to make your request URLs case insensitive with these two directives:
Just the standard stuff

MVC frameworks are pretty standard and are extremely useful. They make a lot of tasks very simple, most notably handling URI routing and creating RESTful interfaces (e.g. how Newgrounds's URIs are setup.) Laravel is solid and pretty straightforward to use if you want to check one out—I'd never not use an MVC framework for developing websites, so I'd highly recommend looking into them.

At 12/5/18 03:31 PM, Aprime wrote: Interesting, I'll look into mod_spelling in general

Note that it's (deliberately) misspelled as mod_speling. Just so you don't trip up Apache trying to include modules that don't exist.

At 12/5/18 03:31 PM, Aprime wrote: Goofy rewrites, that's a shame

Rewrites tend to be, and their rather expensive, so I'd recommend avoiding them whenever possible. A far better way to handle routing, for non-trivial applications at least, is to pass everything to a single script and use server-side code to parse the URI and figure out what to do with it, rather than relying on Apache or nginx or whatever to handle your application's routes for you.

This doesn't apply to static files, though, such as images, and CSS or JS files.

Laravel's docs have a good article on routing with their framework, but the general rule applies to any MVC framework. The essential idea is to define a URI, such as /bbs/topic/{id} for this page, where {id} is a variable, and set it to execute some callback (typically a function.)

So, something like this (this isn't based on any real MVC framework):

function getTopic($id) {
  return renderTemplateById($id, "topic.html");
}

Router::addRoute("/bbs/topic/{id}", getTopic);
At 12/5/18 03:31 PM, Aprime wrote:
What's the reason you're doing this, anyway?
Honestly, nothing more than just a thought after typing in wrong URL's due to casing.

I'd suggest just throwing 404 errors unless you have a compelling reason not to; URIs on websites are typically case-sensitive.

Response to: All CaSinG works for URL? Posted December 4th, 2018 in Programming

Assuming you're not going to be using an MVC framework that would be able to do all of that for you, you can use .htaccess files with mod_speling to make your request URLs case insensitive with these two directives:

CheckSpelling On
CheckCaseOnly On

That will obviously require you to have mod_speling installed. If you can't install that then you'd need to do some goofy rewrites that I wouldn't recommend doing.

What's the reason you're doing this, anyway?

Response to: Execute JS file after references? Posted November 8th, 2018 in Programming

At 11/8/18 06:37 AM, Aprime wrote: Appending doesn't run the script >_<

It does if you use the createElement() function:

var script = document.createElement("script");

script.src = "myfile.js";

document.head.appendChild(script);

You also don't need to set the type attribute for <script> elements; it doesn't really do anything on modern browsers.

edit:

Also, if you're fine with your code not working in older browsers (basically just IE) you can simplify code like this:

document.write('<script src="', 'example', '" type="text/JavaScript"><\/script>');

to this:

document.write(`<script src="${example}"></script>`);

That uses template literals, which make working with strings and variables a lot easier.

Response to: Memory Leak Testing Posted November 5th, 2018 in Programming

I've used Dr. Memory for memory leak tests on Windows in the past and it works pretty good. You could also use std::shared_ptr more frequently and let that class handle the memory for you so you don't need to worry about leaks.

Response to: Point hitTest Posted October 23rd, 2018 in Game Development

You can use the hitTestPoint() function. The function is a public member of all DisplayObject objects, so any MovieClip or Sprite you're using will have it.

Response to: Test Posted August 12th, 2018 in Game Development

Please don't spam the forums.

Response to: Might be the wrong forum Posted July 17th, 2018 in Programming

They could be checking the HTTP_REFERER flag in the HTTP request to see if it came from Google, or they could be using one of Google's APIs to determine that (essentially quering Google's servers to find out if a view came from a Google search.) The latter is more likely as HTTP_REFERER is not trustworthy and can easily be spoofed (or removed entirely.)

At 7/14/18 12:42 PM, sharpnova wrote: https://developer.mozilla.org/en-US/docs/Web/API/Window/history

The History object does not expose the pages previously viewed; it only gives the ability to add or remove from the browser's history or move back/forward in said history. Exposing the previously viewed pages would be a huge security risk, which is why that is not implemented (with the possible exception of very old browsers.)

Response to: Read and write to external doc? JS Posted July 5th, 2018 in Programming

At 7/5/18 07:04 PM, Aprime wrote:
At 7/5/18 06:34 PM, Diki wrote: You can't reliably write to disk from a web browser as that would be a massive security flaw. It's just not something that browsers can do nor should be able to do.

var newDoc = open("../myDoc.csv");
Ohhh, right. If the content that's changing the file is local too, it should be possible?

Maybe. It would entirely depend on the developers of the browser to implement that behavior (e.g. Google or Mozilla.) It's certainly not something I would ever trust to reliably exist as a supported feature due to the security risks involved; it might just disappear one day (if it hasn't already.)

At 7/5/18 07:04 PM, Aprime wrote: I'm just trying to ++ a int when something on the local page has been clicked.

It's kinda pointless and more for the sake of doing it because I'd like to know how.

Cheers

If that's all you want to do then local storage should work. You could just use a basic event listener to check when an element is clicked and save the number of times it has been clicked in local storage:

document.getElementById("ClickMe").addEventListener("click", function() {
  var numberOfClicks = localStorage.getItem("numberOfClicks");

  if (!numberOfClicks) { // Check if 'numberOfClicks' has been stored yet
    numberOfClicks = 0; // If not then assume it should be zero.
  } else {
    numberOfClicks++; // If so then increment it.
  }

  localStorage.setItem("numberOfClicks", numberOfClicks);
});

That will track the number of times you click an element with the id "ClickMe."

Response to: Read and write to external doc? JS Posted July 5th, 2018 in Programming

You can't reliably write to disk from a web browser as that would be a massive security flaw. It's just not something that browsers can do nor should be able to do.

var newDoc = open("../myDoc.csv");

This working in Firefox may just be a quirk. The open() function is really just Window.open() which is used to open a new window with a given URL. Firefox may just be being clever and opening a local file. Is this code being executed locally? It seems odd that Firefox would permit any non-local code disk read permission.

writeToFile("../myDoc.csv, contents");

That isn't a built-in function so you must be using some third-party library if that's working for you,

Anyway, what are you trying to do? If you're just wanting to save data for later use you can use local storage, which is pretty simple to use.

Response to: Post messages using Python Posted June 4th, 2018 in Programming

You're getting that error because you're encoding the entire JSON object, including the "input" key. You only need to encode the object that "input" refers to.

So, you just need to change your object to this:

input =  {'app_id': 'test',
    'call': {
        'component': 'Gateway.getDatetime',
        'parameters': {},
        'echo': 'Hello World!'
    }}

and change your request to this:

r = post("http://www.newgrounds.io/gateway_v3.php", data={"input":dumps(input)})

And then it will work.

You also don't need to send those headers, so I didn't include that.

Response to: .midi files Posted April 12th, 2018 in Game Development

At 4/12/18 03:58 PM, purujeet27 wrote: here is some midi files that you can easily convert - www.freemididownload.com

This thread is over 13 years old. Please don't bump old threads as it's against the forum rules and could result in a ban.

Response to: AS3: Overriding errors Posted April 12th, 2018 in Game Development

At 4/11/18 09:08 PM, Veinom wrote: Well, 11 years later.. I hope it works, thanks!

Please do not bump very old threads without good reason. That is in violation of the forum rules and could result in a temporary ban.

Response to: timeout inside each loop - jQuery Posted April 4th, 2018 in Programming

If you want to have every single setTimeout() cancelled you can store each of the return values of setTimeout() in an array, and then pass each of the elements to clearTimeout(). Something like this would work:

var timeouts = [];

function onCancelTimeouts() {
  timeouts.forEach(clearTimeout);
  timeouts = [];
}

$(elements).each(function(index) {
  var that = this;

  timeouts.push(setTimeout(
    function() {
      dooo stuff
    },
    1000 * index
  ));
});
Response to: Try out my new game! Posted March 12th, 2018 in Game Development

At 2/25/18 04:12 PM, ISRE wrote: p.s. this is my first post so if I violated some kind of rule correct me please!

You haven't. We welcome anyone and everyone to post games that they are working on; they don't need to be hosted on Newgrounds. You're more than welcome to post threads that link off-site to your game and/or to post multiple threads regarding updates to your game(s) (so long as you're not posting an absurd number of threads, such as 15+ per week.)

Response to: The Flash 'Reg' Lounge Posted March 11th, 2018 in Game Development

At 3/10/18 10:43 PM, MSGhero wrote: Just noticed @Diki comments more on necro threads than anyone else here.

Feels good man. Come at me.

Response to: .fla not submittable? Posted March 10th, 2018 in Game Development

At 3/10/18 09:20 AM, ASHTONSPAFFORD wrote:
At 1/1/06 10:04 PM, randomrandomrandom wrote: Hey, I have a problem. A week ago I tried submitting an animation that I made that I thought was pretty good. However, when I tried to submit it, Newgrounds says it can only take .swf files. I tried converting it by changing the file name from stuff.fla to stuff.swf, but it didn't work. Help plz?
wait a fucking second i messed up basically just hit ctrl-enter while in flash it should open up a window to view your animation on loop then look in your files youll now have (insert title here).swf also stuff.fla is something I'm working on -.- that's the name of my sneak peak that got blamed for my movie I'm working on

As @gimmick said: this is an ancient thread you're replying to. Also: the person you're quoting hasn't posted here for over 11 years. Please don't bump old threads.

Response to: Referring to appended elements? JS Posted March 9th, 2018 in Programming

Your event listener for hello2 isn't firing because element doesn't exist when that code is executed—the event listeners can't be attached to elements added in the future, only elements that exist at that point in time. So, you need to execute that bit of code every time you add the hello2 element.

You could also move the function to its own declaration so the anonymous functions don't clutter up the code, something like this:

var items = [];
var items2 = [];

items.push("<div class=\"hello\"></div>");
items2.push("<div class=\"hello2\"></div>");

$("#area").append(items.join(""));

function onClickBox() {
  $("#area2").append(
    $(items2.join("")).click(onClickBox)
  );
}

$(".hello").click(onClickBox);

That will pass the element to the jQuery function where you can add the click event listener, and then pass the return of that function call to append() which will add the element because all jQuery functions return the object that it was called on.

Here's an update of your fiddle that uses that code.

Response to: Where can I get some Sprites? Posted February 26th, 2018 in Game Development

If you're just looking for classic video game sprites, you can get them from The Spriters Resource or The Shyguy Kingdom. You can also get original, free to use sprites from Open Game Art.