[Request] use underscore instead of dash in image name

Discussion and feedback on Construct 2

Post » Thu Aug 21, 2014 1:04 pm

Hello.

When I export a project, C2 generate images with a name like myimage-sheet0.png. For various reasons, I'm using this name in my javascript like a var name. But the dash ( - ) in the name is not useable for a var name in javascript, so I must replace all dashes with underscores ( _ ), and, when my projects count 100+ images, it's veryyyy long.

So, is it possible to generate image with underscore instead of dash in the name ? ( = myimage_sheet0.png)
Or is it possible to have an option in a menu and let the choice to the user ?
Or can I modify it in a C2 property file ?

Thanks,
C2 is awesome!
B
5
Posts: 14
Reputation: 355

Post » Mon Sep 29, 2014 6:49 am

One month later, UP !
B
5
Posts: 14
Reputation: 355

Post » Mon Sep 29, 2014 7:15 am

http://searchengineland.com/9-seo-quirk ... -of-146465

a "-"dash/hyphen is more compatible with the web than an "_" underscore.

just wanted to add, that because construct 2 deals with html5 and the web, this is important. it can potentially help people get to your games. Also works much better with google.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Mon Sep 29, 2014 8:16 am

> obj = {'with-a-dash':1}
{ 'with-a-dash': 1 }
> obj['with-a-dash']
1
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Mon Sep 29, 2014 8:55 am

Tylermon > I don't care about SEO, my games are wrapped in Webview for Android and iOS. But thanks.

Noncentz705 > ???
B
5
Posts: 14
Reputation: 355

Post » Mon Sep 29, 2014 9:07 am

> window['something-dash'] = "something"
"something"
>console.log(window['something-dash'])
"something"
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Mon Sep 29, 2014 9:30 am

Noncentz705 > Could you use words in your sentences ?

A simple
Code: Select all
var myvar-toto = "dada";
throw an error
Code: Select all
Uncaught SyntaxError: Unexpected token -
B
5
Posts: 14
Reputation: 355

Post » Mon Sep 29, 2014 9:52 am

What I posted is =what the repl returns if you were to type it into your browser console ...
Use bracket notation to define/access the key name 'myvar-toto'
window['myvar-toto'] = 'something';
If the variable isn't meant to be global then you wouldn't attach it to the window object and may choose another
var o = {};
o['myvar-toto'] = 'something';

This should be common knowledge if your planning a project with JS.
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Mon Sep 29, 2014 1:47 pm

somonflex wrote:Tylermon > I don't care about SEO, my games are wrapped in Webview for Android and iOS. But thanks.

Noncentz705 > ???


Hyphens are the standard for naming files on the web. You can access javascript items using array syntax myobject['my-field']
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
13
S
4
Posts: 303
Reputation: 1,705


Return to Construct 2 General

Who is online

Users browsing this forum: wmnjunior and 3 guests