0 / 0 / 0
Регистрация: 03.08.2010
Сообщений: 14
1

XNA (Sprite) не понимаю в чем дело

05.08.2010, 15:05. Показов 2742. Ответов 6
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion
 
namespace FirstProjecktBookPDF
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        ContentManager content;
        SpriteBatch spriteBatch;
        KeyboardState keyboardState;
        Texture2D spriteTexture;
        Vector2 spritePosition;
        
 
 
 
        /// <summary>
        /// Konstryktor
        /// </summary>
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            content.RootDirectory = "Content";
            Window.Title = "Pervij proekt. Okonnoe prilozenie";
 
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = false;
 
            Window.AllowUserResizing = true;
        }
 
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
 
        /// <summary>
        ///Initializacija
        /// </summary>
        protected override void Initialize()
        {
            spritePosition.X = Window.ClientBounds.Width/2;
            spritePosition.Y = Window.ClientBounds.Height/2;
            // TODO: Add your initialization logic here
 
            base.Initialize();
        }
 
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent(bool loadAllContent)
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            if (loadAllContent)
            {
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
                spriteTexture = content.Load<Texture2D>(@"Content\\Textures\\sprite.JPG");
            }
 
            // TODO: use this.Content to load your game content here
        }
 
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected  void UnloadContent(bool unloadAllContent)
        {
            if (unloadAllContent == true)
            {
                content.Unload();
            }
            // TODO: Unload any non ContentManager content here
        }
 
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
 
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
 
            
            keyboardState = Keyboard.GetState();
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
 
            // TODO: Add your update logic here
 
            base.Update(gameTime);
        }
 
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(spriteTexture,spritePosition,Color.White);
            spriteBatch.End();
 
            // TODO: Add your drawing code here
 
            base.Draw(gameTime);
        }
    }
}
Выдает ошибки в этом месте :
C#
1
2
3
4
5
6
7
8
9
10
11
protected override void LoadContent(bool loadAllContent)
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            if (loadAllContent)
            {
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
                spriteTexture = content.Load<Texture2D>(@"Content\\Textures\\sprite.JPG");
            }
 
            // TODO: use this.Content to load your game content here
        }
Все делал по книжке.
Подскажите пожалуйста в чем ошибка
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
05.08.2010, 15:05
Ответы с готовыми решениями:

Не понимаю в чем дело
Выдает ошибку не понимаю в чем дело:) Traceback (innermost last): File &quot;__init__2.py&quot;, line...

Не понимаю в чем дело,
гугл выдает такую ощибку по РК &quot;1 кампания без групп объявлений Объявления некоторых кампаний не...

Не понимаю в чем дело с многофайловым приложением
Уважаемые форумчане, только начал изучать C++(точнее 2 день), сделал простенький алгоритм,...

ToolBar отцы и дети. В чём дело не понимаю! научите :(
Пишу модуль для одной проги, всё простенько. Есть там тулбарчик древний. Задача сделать тулбарчик...

6
1274 / 975 / 113
Регистрация: 12.01.2010
Сообщений: 1,971
05.08.2010, 17:50 2
хрустальный шар говорит что ошибка в строке где загружается некий sprite.JPG
так же шар говорит что ошибка что-то типа "не найден такой файл"

как минимум нужно убрать .JPG из названия, если не поможет методом тыка подобрать правильный путь к файлу с учетом что стартовая директория "Content"
1
0 / 0 / 0
Регистрация: 03.08.2010
Сообщений: 14
05.08.2010, 22:41  [ТС] 3
izmenil pyt do risynka no vseravno idyt oshibki
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion
 
namespace FirstProjecktBookPDF
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        ContentManager content;
        KeyboardState keyboardState;
        Texture2D spriteTexture;
        Vector2 spritePosition;
        SpriteBatch spriteBatch;
        
        /// <summary>
        /// Konstryktor
        /// </summary>
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = false;
            graphics.IsFullScreen = true;
            //content.RootDirectory = "Content";
            Window.Title = "Pervij proekt. Okonnoe prilozenie";
 
            Window.AllowUserResizing = true;
        }
 
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
 
        /// <summary>
        ///Initializacija
        /// </summary>
        protected override void Initialize()
        {
            spritePosition.X = Window.ClientBounds.Width / 2;
            spritePosition.Y = Window.ClientBounds.Height / 2;
            // TODO: Add your initialization logic here
 
            base.Initialize();
        }
 
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected  override void LoadContent(bool loadAllContent)
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            if (loadAllContent)
            {
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
                spriteTexture = content.Load<Texture2D>("Textures\\sprite");
            }
 
            // TODO: use this.Content to load your game content here
        }
 
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent(bool unloadAllContent)
        {
            if (unloadAllContent == true)
            {
                content.Unload();
            }
            // TODO: Unload any non ContentManager content here
        }
 
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
 
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
 
            
            keyboardState = Keyboard.GetState();
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
 
            // TODO: Add your update logic here
 
            base.Update(gameTime);
        }
 
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(spriteTexture, spritePosition, Color.White);
            spriteBatch.End();
 
            // TODO: Add your drawing code here
 
            base.Draw(gameTime);
        }
    }
}
0
1274 / 975 / 113
Регистрация: 12.01.2010
Сообщений: 1,971
05.08.2010, 22:54 4
какая ошибка-то...
0
0 / 0 / 0
Регистрация: 03.08.2010
Сообщений: 14
05.08.2010, 23:54  [ТС] 5
Ошибка 1 "FirstProjecktBookPDF.Game1.LoadContent(bool)": не найден метод, пригодный для переопределения K:\ProgecktForVisualStudio\XNA\LessonsInHouse\FirstProject\FirstProjecktBookPDF\ FirstProjecktBookPDF\Game1.cs 70 34 FirstProjecktBookPDF
Ошибка 2 "FirstProjecktBookPDF.Game1.UnloadContent(bool)": не найден метод, пригодный для переопределения K:\ProgecktForVisualStudio\XNA\LessonsInHouse\FirstProject\FirstProjecktBookPDF\ FirstProjecktBookPDF\Game1.cs 86 33 FirstProjecktBookPDF

Добавлено через 20 минут
ispravil vot na tak
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion
 
namespace FirstProjecktBookPDF
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        ContentManager content;
        KeyboardState keyboardState;
        Texture2D spriteTexture;
        Vector2 spritePosition;
        SpriteBatch spriteBatch;
        
        /// <summary>
        /// Konstryktor
        /// </summary>
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = false;
            graphics.IsFullScreen = true;
            //content.RootDirectory = "Content";
            Window.Title = "Pervij proekt. Okonnoe prilozenie";
 
            Window.AllowUserResizing = true;
        }
 
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
 
        /// <summary>
        ///Initializacija
        /// </summary>
        protected override void Initialize()
        {
            spritePosition.X = Window.ClientBounds.Width / 2;
            spritePosition.Y = Window.ClientBounds.Height / 2;
            // TODO: Add your initialization logic here
 
            base.Initialize();
        }
 
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected  override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
           // if (loadAllContent)
          //  {
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
                spriteTexture = content.Load<Texture2D>("Textures\\sprite");
         //   }
 
            // TODO: use this.Content to load your game content here
        }
 
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
           // if (unloadAllContent == true)
           // {
                content.Unload();
          //  }
            // TODO: Unload any non ContentManager content here
        }
 
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
 
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
 
            
            keyboardState = Keyboard.GetState();
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
 
            // TODO: Add your update logic here
 
            base.Update(gameTime);
        }
 
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(spriteTexture, spritePosition, Color.White);
            spriteBatch.End();
 
            // TODO: Add your drawing code here
 
            base.Draw(gameTime);
        }
    }
}
posle kompiljacii i zapyska ekran chernij i nikakih izmenenij
0
1274 / 975 / 113
Регистрация: 12.01.2010
Сообщений: 1,971
06.08.2010, 01:17 6
ну черным-то он никак не должен быть..как минимум цвета CornflowerBlue

убери graphics.IsFullScreen = true;
потом убедись что sprite.jpg это не черный квадрат с размером типа 1024*768...
1
0 / 0 / 0
Регистрация: 03.08.2010
Сообщений: 14
06.08.2010, 14:49  [ТС] 7
na fotografii vertolet
ybral to chto vi govorili

kompilit no sam Windows govorit chto proizoshli oshibki s otkritiem etoj programmi
0
06.08.2010, 14:49
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
06.08.2010, 14:49
Помогаю со студенческими работами здесь

Не понимаю в чем дело, сильно тупит командная строка в windows 10
Доходит до того, что он просто не может открыть файл (когда указываешь путь к файлу (полный)),...

Немного исправить ошибки. Тема: стэки, списки, очереди. Не понимаю в чем дело
// 15.cpp: определяет точку входа для консольного приложения. // #include &quot;stdafx.h&quot; #include...

Генератор карт через структуру (список), странная ошибка, не понимаю в чём дело
Есть значит у меня структура, в которой храниться Id, вес карты, и ссылка на картинку в программе....

выдает ошибку :[C++ Error] Unit1.cpp(30): E2034 Cannot convert 'char' to 'char *' не понимаю в чем дело
//Дано предложение. Найти наибольшее количество идущих подряд пробелов #include &lt;vcl.h&gt;...

XNA или Monogame? Чем Monogame лучше XNA?
Добрый день! Занимаюсь разработкой игр на xna на vcs2010. Вроде все хорошо идет, но тут наткнулся...

5 короткий сигналов биос, может ли дело быть в чем то другом чем в процессоре?
Комп врубается однако он никак не реагирует на мышь и клавиатуру, даже заходит во вход в Windows,...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
7
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru