//
// GameScence.hpp
// NotesDamo
//
// Created by apple on 16/10/23.
//
// #ifndef GameScence_hpp
#define GameScence_hpp #include <stdio.h>
#include "cocos2d.h" class GameScence : public cocos2d::Layer
{
private:
//创建一个私有的精灵成员变量
cocos2d::Sprite * m_spriteGun;
public: static cocos2d::Scene* createScene();//声明创建当前的层 virtual bool init();//声明初始化层实例函数。 bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);//手势点击事件 CREATE_FUNC(GameScence);//CREATE_FUNC是cocos2d-x中定义的一个宏(作用是:创建一个静态函数"static create()",该函数可以用来创建层); };
#endif /* GameScence_hpp */
 //
// GameScence.cpp
// NotesDamo
//
// Created by apple on 16/10/23.
//
// #include "GameScence.hpp" USING_NS_CC; Scene* GameScence::createScene()
{
auto scene = Scene::create(); auto layer = GameScence::create(); scene->addChild(layer); return scene;
} GameScence::GameScence()
{ }
bool GameScence::init()
{
//////////////////////////////
// 1. super init first
// 初始化父类
if ( !Layer::init() )
{
return false;
} m_spriteGun = Sprite::create(StringUtils::format("gun2_0.png"));
m_spriteGun->setPosition(, );
this ->addChild(m_spriteGun); //声明
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true); //注册事件
listener->onTouchBegan = CC_CALLBACK_2(GameScence::onTouchBegan, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); return true;
} bool GameScence::onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)
{ touch->getLocation();// 获取当前点击的坐标 m_spriteGun->cocos2d::Node::setRotation(atan2((touch->getLocation().x-m_spriteGun->getPositionX()),(touch->getLocation().y-m_spriteGun->getPositionY()))*/3.1415926);//改变弧度 后面加不加90要根据精灵的初始角度是怎样的 return true;
}

cocos2dx 3.x(捕鱼达人炮台角度换算)的更多相关文章

  1. Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent

    Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱 ...

  2. cocos2dx游戏开发——捕鱼达人mini版学习笔记(二)——MainMenu的搭建

    一.创建文件~ MainMenuScene.h   MainMenuScene.cpp   MainMenuLayer.h   MainMenuLayer.cpp 那个场景的搭建就不多说了,那个我的打 ...

  3. cocos2dx游戏开发——捕鱼达人mini版学习笔记(一)——FishAchor的搭建

    一.创建文件· FishAchor.h还有FishAchor.cpp. 主要就是创建每种鱼的类,方便以后的取用~,很多是重复性的操作,然后我们是mini版,暂时也就加入大概6钟鱼就好= =,然后我们现 ...

  4. 【Cocos2d-x for WP8 学习整理】(3)CCScrollView 实现捕鱼达人一样的场景选择界面

    UI 界面一般是游戏里比较独立的地方,因为游戏引擎一般都比较注意基础的功能封装,很少会关注UI,但是 UI 确是玩家第一眼看到的效果,因此能否实现一个美观的UI对于提升游戏的整体美观有着很大的帮助. ...

  5. js原生捕鱼达人(三)--完结

    先给分享下我写完的效果,github有点卡,我没有压缩代码,不过效果可以看到 https://jasonwang911.github.io/ 转载请注明'转载于Jason齐齐的博客http://www ...

  6. js原生捕鱼达人(一)

    捕鱼达人的游戏大家都很熟悉吧,接下来的两三天,我会将整个游戏的原生js写法详细的写出来,整个游戏应用了面向对象的写法:创建构造函数,在构造函数上面添加对象的属性,然后在构造函数的原型上添加方法,当然这 ...

  7. TOP30专访:捕鱼达人陈昊芝

    原文:http://www.csdn.net/article/2012-04-04/313919/1 编者按:3月31日,第四届CocoaChina游戏开发者大会暨Cocos2D-X技术研讨会在北京举 ...

  8. 利用ZjDroid对 <捕鱼达人3> 脱壳及破解过程-转

    http://blog.sina.com.cn/zihao2015 <捕鱼达人3> 刚出来不久,就被鬼哥Dump出来dex,随之破解也就轻而易举.一开始我用ZjDroid神器试验过,但是没 ...

  9. html5 canvas简易版捕鱼达人游戏源码

    插件描述:html5利用canvas写的一个js版本的捕鱼,有积分统计,鱼可以全方位移动,炮会跟着鼠标移动,第一次打开需要鼠标移出背景图,再移入的时候就可以控制炮的转动,因为是用的mouseover触 ...

随机推荐

  1. linux系统

    ● ubuntu提示"sudo: unable to resolve host volcano: No such file or directory" 修改/etc/hosts,在 ...

  2. Maven问题总结:could not resolve archetype xxxxxxx from any of the configured repositories

    错误提示 Eclipse中通过Archetype创建Maven项目时报错:Could not resolve archetype xxxxxxx from any of the configured ...

  3. 19. 求平方根序列前N项和

    求平方根序列前N项和 #include <stdio.h> #include <math.h> int main() { int i, n; double item, sum; ...

  4. python多线程使用

    内容链接: http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138683236 ...

  5. Unity 区分不同平台

    问题:公司开发的游戏实在android平台上运行,但是我们是在windows平台下进行开发,OK ,经常有些地方开发完之后就要换到android上面,能区分平台的不同就可以对代码做区分处理 回答:un ...

  6. simplify the design of the hardware forming the interface between the processor and thememory system

    Computer Systems A Programmer's Perspective Second Edition Many computer systems place restrictions ...

  7. url如何传递参数

    $(document).ready(function() { var name=getQueryString('minename'); if (name != null && name ...

  8. Delphi 记录类型- 结构指针

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  9. java CyclicBarrier 2

    //Listing 6-2. Using a Cyclic Barrier to Decompose a Task into Subtasks import java.util.concurrent. ...

  10. [dpdk] 读开发指南(2)(内容长期整理中)

    接续前节. 7 PMD (Poll Mode Driver) A Poll Mode Driver (PMD) consists of APIs, provided through the BSD d ...